Detailed explanation of the use of pip in Python | summary of third-party library installation

**First, let's briefly introduce what pip is? **

pip is a third-party library manager for python. You can use pip-related commands to install different libraries according to the needs of the developed project.

After Pyhon 3.4, pip is installed with Python by default. The location of pip in the python installation directory is as follows:

Execution method: Run [win+R]+cmd and execute pip to check whether the installation is successful. (Cannot find the command, you need to manually add to the environment variable)

Python officially provides a pypi library (https://pypi.org/). All third-party libraries are published here, and everyone can install it directly through pip.

pip common basic commands

**Check the installed third-party libraries: **pip list

**Install the library directly: **pip install library name

**Specify version installation: **pip install robotframework==2.8.7

**Uninstall the installed library: **pip uninstall requests

**Update a library: ** pip install -U requests

**Check the pip version: **pip --version

**Pip tool upgrade: **python -m pip install --upgrade pip

Third-party library installation method

1. Online installation

pip install library name

But sometimes, the network is unstable and the installation often fails. If the timeout error is reported, you can try several times. Generally, most libraries can be installed in this way. If it still fails, you can use the following domestic source installation.

**Domestic source installation: **

Use the parameter i to specify the pip source

For example:

pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple

Domestic source mirror

Alibaba Cloud http://mirrors.aliyun.com/pypi/simple/

University of Science and Technology of China https://pypi.mirrors.ustc.edu.cn/simple/

Douban http://pypi.douban.com/simple/

Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple/

University of Science and Technology of China http://pypi.mirrors.ustc.edu.cn/simple/

There is another way, through pycharm installation, you can try it on Baidu.

2. Offline installation

wheel format file installation (recommended)

Step1. Download the required library wheel file in the following link.

http://www.lfd.uci.edu/~gohlke/pythonlibs/

Step2.cmd enter the directory where the whl file is located and execute pip install whl file name

Folder installation method (setup.py):

Step1: First download the required installation package at https://pypi.org/

Step2: Unzip the file.

Step3: Switch to the directory of the package to be installed by the command line tool cd, find the setup.py file, and enter python setup.py install

After installation, where can I see it

Other tips

Export all local package names and version numbers

When you need to switch the environment or share the project with others, in order to ensure the consistency of the operating environment, you need to export the package name and version number that the project depends on.

**Use the pip freeze command to export the local software package and version number. **

Add the local library and version number to the requirements.txt file:

pip freeze > requirements.txt

Open the requirements.txt file, as shown below:

How to install this file after others get it

pip install -r requirements.txt

Recommended Posts

Detailed explanation of the use of pip in Python | summary of third-party library installation
Detailed explanation of the installation and use of SSH in the Ubuntu environment
Detailed explanation of the principle of Python super() method
Detailed explanation of python standard library OS module
Detailed explanation of the usage of Python decimal module
Detailed explanation of the principle of Python function parameter classification
Detailed explanation of the principle of Python timer thread pool
Detailed explanation of the implementation steps of Python interface development
Installation and use of GDAL in Python under Ubuntu
Detailed explanation of the attribute access process of Python objects
Detailed explanation of the remaining problem based on python (%)
The usage of wheel in python
Summary of logarithm method in Python
Detailed explanation of python backtracking template
Use of Pandas in Python development
Detailed explanation of python sequence types
Detailed use of nmcli in CentOS8
Use of numpy in Python development
What is the use of Python
Detailed usage of dictionary in Python
The usage of tuples in python
Understanding the meaning of rb in python
What is the use of python's pip
The usage of Ajax in Python3 crawler
Detailed explanation of Python IO port multiplexing
Analysis of glob in python standard library
Where is the pip path of python3
The essence of Python language: Itertools library
Python novice learns to use the library
Detailed explanation of -u parameter of python command
Detailed explanation of Python guessing algorithm problems
The specific method of python import library
What is the function of adb in python
How to use the round function in python
How to use the zip function in Python
Python implements the shuffling of the cards in Doudizhu
The meaning and usage of lists in python
How to use the format function in python
Detailed explanation of how python supports concurrent methods
The consequences of uninstalling python in ubuntu, very
Detailed explanation of data types based on Python
Introduction to the use of Hanlp in ubuntu
Installation and use of SSH in Ubuntu environment
A brief summary of the difference between Python2 and Python3
Detailed explanation of common tools for Python process control
Detailed explanation of Python web page parser usage examples
How to understand the introduction of packages in Python
Detailed installation steps of CentOS6.4 system in virtual machine
Detailed explanation of CentOS7 network setting tutorial in vmware
How to find the area of a circle in python
Learn the hard core operation of Python in one minute
Detailed explanation of Spark installation and configuration tutorial under centOS7
A large inventory of commonly used third-party libraries in Python
Linux overview of Python automated operation and maintenance and the ultimate guide to virtual machine installation and use
Consolidate the foundation of Python (4)
Consolidate the foundation of Python(7)
Subscripts of tuples in Python
Consolidate the foundation of Python(6)
Use of Anaconda in Ubuntu
Consolidate the foundation of Python(5)
Python version of OpenCV installation