错误描述
我在使用 pip 安装本地的一个库时,报如下错:
Processing e:\installapp\sysplorernewkernel_main\3038\app\sysplorer 2024a\tools\sysplorer_python_api\mworksengine-1.0.tar.gz
Preparing metadata (setup.py) ... done
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000202BB2DF640>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))': /simple/websocket-client/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000202BB2DF880>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))': /simple/websocket-client/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000202BB2DFB50>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))': /simple/websocket-client/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000202BB2DFC70>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))': /simple/websocket-client/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x00000202BB2DFD90>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))': /simple/websocket-client/
INFO: pip is looking at multiple versions of mworksengine to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement websocket-client (from mworksengine) (from versions: none)
ERROR: No matching distribution found for websocket-client
在网上搜索一大堆解决方案也没有得到解决,据观察很多人如下方式解决,但在我的电脑上尝试无用。
pip install xxx -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
解决方案
① 删除所有镜像源
一气之下,我将全部国内源卸载(之前装了四五个清华源和豆瓣),全部替换为默认源(如下)。
pip config unset global.index-url
再次执行安装命令,成功!!!
Downloading websocket_client-1.7.0-py3-none-any.whl.metadata (7.9 kB)
Collecting jsonrpcclient (from mworksengine==1.0)
Downloading jsonrpcclient-4.0.3-py3-none-any.whl.metadata (3.2 kB)
Requirement already satisfied: colorama in e:\installapp\anacond\envs\pyqt_py38\lib\site-packages (from mworksengine==1.0) (0.4.6)
Collecting psutil (from mworksengine==1.0)
Downloading psutil-5.9.8-cp37-abi3-win_amd64.whl.metadata (22 kB)
Downloading jsonrpcclient-4.0.3-py3-none-any.whl (7.0 kB)
Downloading psutil-5.9.8-cp37-abi3-win_amd64.whl (255 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 255.1/255.1 kB 9.7 kB/s eta 0:00:00
Downloading websocket_client-1.7.0-py3-none-any.whl (58 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.5/58.5 kB 14.0 kB/s eta 0:00:00
Building wheels for collected packages: mworksengine
Building wheel for mworksengine (setup.py) ... done
Created wheel for mworksengine: filename=mworksengine-1.0-py3-none-any.whl size=19646 sha256=58d40e4a016dc24830d057be8ad5d5f2f278893625212597490e03f7643d98be
Stored in directory: c:\users\tr\appdata\local\pip\cache\wheels\48\74\a5\80bdda777747241f52b966bc128e9863480c970c5799fc5466
Successfully built mworksengine
Installing collected packages: websocket-client, psutil, jsonrpcclient, mworksengine
Successfully installed jsonrpcclient-4.0.3 mworksengine-1.0 psutil-5.9.8 websocket-client-1.7.0
但是我觉得先卸载所有源重新加载下应该就好了,因为那个报错显示url地址发生了更改,导致下载路径找不到了。
② 修改pip.ini文件配置
在 C:\Users\TR\AppData\Roaming\pip
目录下打开pip.ini
文件,在其中添加:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple
trusted-host = mirrors.aliyun.com
【注】:如果没有 pip 文件夹,就自行创建一个,在添加上述的 .ini文件