Get the App
SLTechnology News&Howtos  ›  Development  › 

How to install and use pip in Python

Shulou Source: shulou.com Published: 2022-06-01 13:34:14 11月14日 Update

Today, the editor will share with you the relevant knowledge points about how to install and use pip in Python. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

1. Pip online installation

In the cmd command line mode, install the third-party library directly in the form of the name of the pip install third-party library.

Let's take the installation of plotly as an example, and the installation is as follows:

Pip install plotly

If the third-party library that needs to be installed already exists, we will prompt for its existence and show the location of the library installation when we execute the installation command, as shown below:

If you want to uninstall third-party libraries, you can uninstall third-party libraries directly in the form of the name of the pip uninstall third-party library.

Of course, you may encounter a lot of other problems in the actual installation process, including the following two situations:

Installation timeout (because online installation, the source where the third-party library is located will be requested, the default source is overseas, and our request may be too slow to cause a timeout, etc.)

Version number mismatch (because there may be some other libraries in our python environment, and there may be dependencies between libraries, if the installed version of the library is too new or too old, it may not match the existing library and cannot be installed normally)

In the case of installation timeout, if we continue to use the online installation mode of pip, we can specify the domestic source at the time of installation. The instructions are as follows:

Pip install plotly-I https://pypi.tuna.tsinghua.edu.cn/simple

If the version number does not match, we can specify the version number at the time of installation if we continue to use the online installation mode of pip. The instructions are as follows:

Pip install plotly==4.9

There are several ways to specify a version number:

If not specified, the latest is installed by default

= = specify a specific version number

= specify the minimum version number

< 不高于某版本号 >

No less than a certain version number

For cases where a specific version number is not specified, it is important to note that the form of the command is slightly different: the relationship between the third-party library and the version number needs to be in quotation marks ("), otherwise an error will occur.

Pip install "plotly

Tags: Version third party time online situation name command file method upgrade form environment knowledge article hint code content internal source can be passed instruction Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Microsoft Shulou Information Docker OPPO Reno