Python learning notes-use pip to install the module, pythonpip
We often need to install various modules when using Python, while pip is a very powerful module Installation tool. Similar to linux Yum, It can automatically resolve dependencies when installing modules. The following is a summary:
1. Install pip:
Pip is automatically installed when python is installed.
Ii. pip:
1. Upgrade pip
Python-m pip install -- upgrade pip
2. Installation Module
Pip install gevent# Install a specified Module
Pip install-r requirements.txt# Install the list of modules defined in the requirements.txt File
3. Change pip Source
Pip when installing third-party modules, by default from the Python official module library: https://pypi.python.org download, but because often blocked by the firewall or download speed is slow, so you need to replace the domestic Image
There are many available sources on the Internet, such
Douban: http://pypi.douban.com/simple/
Tsinghua https://pypi.tuna.tsinghua.edu.cn/simple
Recently used more and more handy is the pip source of Tsinghua University, it is the official pypi image, every 5 minutes synchronization, address for 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 install the gevent library from the image on Tsinghua side.
2,Permanent modification, once and for all:
In Linux, modify ~ /. Pip/pip. conf (create one if there is no one), modify index-url to tuna, the content is as follows:
[Global]
Index-url = https://pypi.tuna.tsinghua.edu.cn/simple
In Windows, create a pip directory in the user directory, for example, C: \ Users \ xx \ pip. Create the pip. ini file. The content is as follows:
[Global]
Index-url = https://pypi.tuna.tsinghua.edu.cn/simple