Skip to content

Friends who often play with AI tools, especially open-source tools, will inevitably encounter situations where they need to use Python for local deployment. Then you will inevitably encounter many pip-related errors. For example, when installing with pip install xxx, the speed is very slow, a few KB/s. For models that are several GB in size, it will take forever to download.

Sometimes it cannot be downloaded directly, prompting cannot connect huggingface.co. After finally configuring the scientific internet access environment, another error occurs, with errors such as proxyError and max retries emerging one after another.

Now let's simply deal with these issues.

1. Slow Download Speed

The pip download source is abroad. As we all know, for various reasons, domestic downloads will inevitably be slow.

Temporarily Use Alibaba Cloud Mirror

If you are only installing one module, or use it occasionally, you can specify to use the Alibaba Cloud mirror after the command. The method is as follows:

bash
pip install  xx模块名 -i  http://mirrors.aliyun.com/pypi/simple/ --trusted-host  mirrors.aliyun.com

Permanently Change to Alibaba Cloud Mirror

If you use it frequently, the temporary method is very inconvenient. At this time, on Windows, open [Computer] --> [C drive] --> [Users] --> [Your User Name] --> [pip folder (create if it doesn't exist)]. Open the pip.ini file inside. Similarly, if this file does not exist, create it, note that the suffix extension is .ini instead of .txt.

Then clear the contents and replace it with:

ini
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

Permanently specify the mirror in pip.ini

What if I want to use other mirror sources? Such as Tsinghua University? The method is the same, the only difference is index-url and trusted-host. Replace them according to the provided method.

ini
# 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.cn

2. I have already used a domestic mirror, but still report a bunch of errors?

Check carefully whether there is a proxyError or Retrying (Retry(total=4 error in the error message, as shown in the figure below:

Errors caused by using a proxy

Domestic mirrors do not allow downloading with foreign IP addresses. If this error occurs, please turn off the proxy, or reverse the operation according to the above method and delete pip.ini to use the official default pip source.

3. A bunch of red errors, with many version numbers

Error as shown below:

The specified version number does not exist

This error indicates that the version you specified does not exist. Only the version numbers after from versions: can be installed. At this time, you can find a version that is closest to the version number you specified, and the first version number is the same to install.

For example, pip install requests==2.32.0, you want to install this version, but it does not exist. As shown in the figure above, observe that the version starts with 2., and the closest version number is 2.32.2, then the command can be changed to pip install requests==2.32.2.

You may also encounter other problems, especially conflicts between modules. For example, two modules a and b both need to use module c, but a needs version 1.2 of c, but b needs version 3.6 of c, which causes a conflict. The specific choice can only be determined on a case-by-case basis.