We often need to install a variety of modules when using Python, and Pip is a very powerful module installation tool, similar to the Linux yum, the installation of modules can automatically resolve dependencies, etc., summarized as follows:
First, install PIP:
PIP is installed automatically when you install Python
Second, use PIP:
1. Upgrade Pip
python-m pip Install--upgrade pip
2. Installation Module
pip install gevent #安装指定模块
pip install-r requirements.txt # List of modules defined in the installation requirements.txt file
Third, change the PIP source
When the PIP installs the third party module, the default from the Python official module library: https://pypi.python.org download, but due to often blocked by the firewall or slow download, and so on, so need to replace the next domestic mirror
There are many sources available on the web, such as
Watercress: http://pypi.douban.com/simple/
Tsinghua: Https://pypi.tuna.tsinghua.edu.cn/simple
Recently used more and more handy is Tsinghua University's PIP source, it is the image of the official website PyPI, every 5 minutes synchronization, the address is https://pypi.tuna.tsinghua.edu.cn/simple
1. Temporary use:
You can add the parameter-I https://pypi.tuna.tsinghua.edu.cn/simple when using PIP
For example: Pip install-i https://pypi.tuna.tsinghua.edu.cn/simple gevent, this will be from the Tsinghua side of the mirror to install the Gevent library.
2, permanent modification, once and for all :
Under Linux, modify the ~/.pip/pip.conf (without creating one), modify Index-url to tuna, and read as follows:
[Global]
Index-url = Https://pypi.tuna.tsinghua.edu.cn/simple
Under Windows, create a PIP directory directly in the user directory, such as: C:\Users\xx\pip, new file Pip.ini, the following
[Global]
Index-url = Https://pypi.tuna.tsinghua.edu.cn/simple
Python Learning notes-using PIP to install modules