python使用pip install导入依赖报错ProxyError(‘Cannot connect to proxy.‘, OSError(0, ‘Error‘))
windows环境下执行。
·
windows环境下执行pip install xxxx
老是报错:
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /pypi/simple/scrapy/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /pypi/simple/scrapy/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /pypi/simple/scrapy/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /pypi/simple/scrapy/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /pypi/simple/scrapy/
ERROR: Could not find a version that satisfies the requirement scrapy
ERROR: No matching distribution found for scrapy
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError(‘Cannot connect to proxy.’, NewConnectionError…
方法一(全局设置)
先执行:
pip config set global.proxy http://mirrors.aliyun.com/pypi/simple/
执行完后出现一个文件,并给出了地址:
C:\Users\Administrator\AppData\Roaming\pip\pip.ini
打开文件,再替换里面的内容:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
方法二(临时)
将【yourpackage 】替换成你需要的依赖
pip install yourpackage -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
建议使用第一种。我就是第一种方式解决的

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)