Common PIP source in China
source | link |
---|---|
Ali 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/ |
USTC | http://pypi.mirrors.ustc.edu.cn/simple/ |
Temporary use
-i + URL, for example:
pip install selenium -i http://pypi.douban.com/simple
Copy the code
If an HTTP source is used, the following error is reported (HTTPS sources are fine) :
WARNING: The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host pypi.douban.com'.
Copy the code
To trust the host, use –trusted-host:
pip install selenium -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
Copy the code
If there is an error:
ERROR: Cannot unpack file C:\Users\issusers\AppData\Local\Temp\pip-unpack-6x9ra6uh\simple.html (downloaded from C:\Users\issusers\AppData\Local\Temp\pip-req-build-zoljdd4t, content-type: text/html); cannot detect archive format
ERROR: Cannot determine archive format of C:\Users\issusers\AppData\Local\Temp\pip-req-build-zoljdd4t
Copy the code
Note The required package may not be synchronized to this source. You can change the source to download the package.
Set the PIP source permanently
By editing the configuration file
In the root directory of the current user, create the.pip directory and edit the configuration file
mkdir ~/.pip
tee ~/.pip/pip.conf <<-'EOF'
[global]
timeout=600
index-url=https://mirrors.aliyun.com/pypi/simple/
trusted-host=mirrors.aliyun.com
EOF
Copy the code
If it is an HTTP source, you need to add trusted-host=mirrors.aliyun.com at the end of the profile
If you are using Windows, create a.pip folder in the user’s home directory and write the pip.conf configuration file.
The specific path is C:\Users\{your system username}\.pip\pip.conf
Configure the PIP source by command line <– recommended, high efficiency
If you don’t want to write a configuration file, you can configure the PIP source with a command that will automatically generate the above directories and files after upgrading PIP to the latest version (>=10.0.0) :
# upgrade PIP
pip install -i https://mirrors.aliyun.com/pypi/simple/ pip -U
# Generate PIP profile
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
Copy the code