最近几门课程都用到了pip安装,结果我每次都会遇到一些奇奇怪怪的问题,身边都没有人遇到过相似的问题,只好自己努力找办法,所幸解决了一些。
下面是我经过痛苦挣扎后找到的解决方案,希望能够帮助到你
问题一:
pip install XXX时,明明已经用了国内的镜像源,却还是被提醒:Could not find a version that satisfies the requirement ….,这是我在用pip安装opencv时遇到的问题
解决方法:
可以看这位大佬的解决方法:(33条消息) 在python中安装包出现Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))_lsf_007的博客-CSDN博客
上面这篇文章里给出了几个国内的镜像源,可以换着试试哦。
总之记住以下几点:
1:清华镜像源(https)不行,那就改成阿里云镜像源(http开头)
2:还不行那就在命令后加上一个trust开头的语句:阿里云镜像源举例:
# 改前
pip install XXX -i http://mirrors.aliyun.com/pypi/simple/
# 改后
pip install XXX -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
问题二:
pip install XXX时(我是安装MindSpore时),被提醒:WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ProtocolError(‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’))’:xxxxxxxxxxxxxxxx
这里的ProtocolError指协议差错,为啥会出现协议差错我也没深究,但是看了一堆网上的解决方法,摸摸索索总算找到了解决办法:
解决办法:
把https通通改成http!!!把你的带https的镜像源的也换成带http的镜像源!!!总之这种情况就是跟https过不去。
可以看这是我在MindSpore官网得到的安装命令:
我把安装命令拷了下来:pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.7.0/MindSpore/cpu/x86_64/mindspore-1.7.0-cp39-cp39-win_amd64.whl –trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple
结果出现以下错误:
错误代码:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ProtocolError(‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’))’: /1.7.0/MindSpore/cpu/x86_64/mindspore-1.7.0-cp39-cp39-win_amd64.whl
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ProtocolError(‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’))’: /1.7.0/MindSpore/cpu/x86_64/mindspore-1.7.0-cp39-cp39-win_amd64.whl
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ProtocolError(‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’))’: /1.7.0/MindSpore/cpu/x86_64/mindspore-1.7.0-cp39-cp39-win_amd64.whl
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ProtocolError(‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’))’: /1.7.0/MindSpore/cpu/x86_64/mindspore-1.7.0-cp39-cp39-win_amd64.whl
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ProtocolError(‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’))’: /1.7.0/MindSpore/cpu/x86_64/mindspore-1.7.0-cp39-cp39-win_amd64.whl
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host=’ms-release.obs.cn-north-4.myhuaweicloud.com’, port=443): Max retries exceeded with url: /1.7.0/MindSpore/cpu/x86_64/mindspore-1.7.0-cp39-cp39-win_amd64.whl (Caused by ProtocolError(‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’)))
简直一头雾水,纠结了好久,我先把官网给的代码中的https改成了http,跑起来了,我欣喜若狂,结果跑到一半断了,又出现了一大堆错:
总之出现了新问题就解决,按照之前的方法,出现Could not find a version that satisfies the requirement…….这种错误,就http开头的镜像源+trust
以上终于成功了(心累了真的)
希望这篇文章能帮到你,欢迎指出错误的地方
文章出处登录后可见!