Article directory
1 pip configuration download mirror source in python
pip is a third-party dependency package management container that manages python
1.1 Windows configuration pip download source
Create a pip directory in the c:\user\username directory, create a new pip.ini file in the directory, and enter the following content:
In the C:\Users\Administrator\pip\pip.ini file, what I configured is:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
Other redundant configuration:
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
When using the third-party package, if Tsinghua Source is configured, it will automatically download from this address.
1.2 Unix/类Unix
Create a hidden pip directory in your home directory , and then create a configuration file named pip.conf . Enter the following content in the pip.conf file.
[root@~]# mkdir ~.pip
[root@~]# vim ~.pip/pip.conf
[root@~]# cat ~/.pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
2 Command line modification method
(1) Command line temporary modification method
When using pypi to download a python package, you can directly use the pip install packagename -i parameter to specify the URL of the download source.
pip install ping3 -i https://pypi.tuna.tsinghua.edu.cn/simple
(2) Command line permanent modification method
Use pip config set global.index-url to directly specify the URL of the download source, so you don’t have to manually modify the configuration file.
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
3 Domestic source URL sharing
The following is the commonly used pypi installation source URL on the domestic Internet. The download speed on the domestic Internet is very fast.
pypi 清华大学源:https://pypi.tuna.tsinghua.edu.cn/simple
pypi 腾讯源:http://mirrors.cloud.tencent.com/pypi/simple
pypi 阿里源:https://mirrors.aliyun.com/pypi/simple/
pypi 豆瓣源 :http://pypi.douban.com/simple/
4 others
4.1 Check the Python version and pip version
python --version
pip --version
4.2 Search for Python third-party libraries that need to be installed
pip search 库名
4.3 Install Python third-party libraries
pip install 库名
或者使用:
python -m pip install requests
下载后python文件中导包:
import requests
4.4 Uninstall Python third-party libraries
pip uninstall 库名
pip list
4.5 Specify the version number of the library
pip install 库名==版本号
4.6 Upgrade Python third-party library
pip install --upgrade 库名
python -m pip install --upgrade pip