Solve the problem of pip or magic download failure when the proxy is turned on
I. Introduction
Due to the frequent environment configuration recently, I always have to switch back and forth in the clang to turn off the agent, which is very inconvenient
As shown below, the download of the magic model fails
ValueError: invalid model repo path HTTPSConnectionPool(host='www.modelscope.cn', port=443): Max retries exceeded with url: /api/v1/models/damo/cv_unet_universal-matting (Caused by ProxyError(' Unable to connect to proxy', SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)'))))As shown below, pip Download failed after changing source
2. Solution
1. Temporary plan
The temporary solution is very simple, just turn off the agent. But if you want to install many packages, it will be very troublesome and you have to switch the agent on and off repeatedly. We recommend the permanent solution below.
2. Permanent solution
Since the pip mirror source (whether Tsinghua or Alibaba) blocks the proxy server, we should not use the proxy network when accessing the mirror source. In the system's proxy settings, directly isolate the domain name of the mirror source:
means in the proxy server settings, do not use the proxy server for the addresses starting with the following entries. Taking Tsinghua University as an example, add pypi.tuna.tsinghua.edu.cn. Note that the addresses are separated by semicolons.
If there are other errors, observe the URL following Looking in indexes:. Extract its domain name and add it to the one above, so you can skip the proxy.
For example, if it is the above situation, you only need to add mirror.baidu.com;
Similarly, if it is the Moda community, the download of the model fails, as shown below
Add the host: www.modelscope.cn to the above setting without proxy. Can.
Note: Sometimes multiple domain names are used. After failure, add the unadded domain names and download again. (Depending on the situation, it depends on whether you need to delete the files that failed to download)