If you often use AI tools, especially open-source ones, you'll inevitably need to deploy Python locally. In such cases, you're likely to run into various pip-related errors, such as extremely slow installation speeds—just a few KB/s—when running pip install xxx. For models that are several gigabytes in size, this means downloads could take forever.
Sometimes, downloads fail outright with errors like cannot connect huggingface.co. Even after setting up a proxy for better access, new issues like proxyError or max retries keep popping up.
Let's address these problems step by step.
1. Slow Downloads
pip's default source is located overseas, and due to various reasons, downloads from within China are inevitably slow.
Temporarily Use Alibaba Cloud Mirror
If you're installing a module occasionally or just once, you can specify the Alibaba Cloud mirror in the command as follows:
pip install module_name -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.comPermanently Switch to Alibaba Cloud Mirror
For frequent use, the temporary method is inconvenient. On Windows, navigate to: 【Computer】→【C: Drive】→【Users】→【Your Username】→【pip folder (create it if it doesn't exist)】. Open the pip.ini file inside (create it if it doesn't exist, ensuring the extension is .ini, not .txt).
Clear the file's contents and replace them with:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
What if you want to use other mirrors, like Tsinghua University's? The method is the same; only the
index-urlandtrusted-hostvalues need to be replaced according to the mirror's instructions.
# Douban:
[global]
index-url = https://pypi.douban.com/simple/
[install]
trusted-host=pypi.douban.com
# Tsinghua University:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
# University of Science and Technology of China:
[global]
index-url = https://pypi.mirrors.ustc.edu.cn/simple/
[install]
trusted-host=pypi.mirrors.ustc.edu.cn2. Still Getting Errors After Using a Domestic Mirror?
Check the error messages carefully for terms like proxyError or Retrying (Retry(total=4, as shown below:

Domestic mirrors do not allow downloads from foreign IP addresses. If you see such errors, turn off your proxy or revert the changes by deleting the pip.ini file to use the default pip source.
3. A Bunch of Red Errors with Many Version Numbers
Errors like the one below:

This error indicates that the specified version does not exist. Only the versions listed after from versions: are available for installation. Choose the version closest to your specified one that shares the same first version number.
For example, if you run pip install requests==2.32.0 but that version doesn't exist, observe the available versions. If the closest version starting with 2. is 2.32.2, change the command to pip install requests==2.32.2.
You might encounter other issues, especially conflicts between modules. For instance, if both modules a and b require module c, but a needs version 1.2 of c while b needs version 3.6, this creates a conflict. The choice depends on the specific situation.
