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.
**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
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.
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
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