赞
踩
网上查的那些加上--trusted-host
对我的问题没有作用,以下是尝试了多种方式得到的解决方法。
目标是为了安装pymysql库。
C:\WINDOWS\system32>pip install pymysql
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
ERROR: Could not install packages due to an OSError: Missing dependencies for SOCKS support.
从以上提示,得知是因为用了vitual proxy network配置。进行了如下尝试:
先在cmd中查看 echo http_proxy 以及https_proxy
在cmd中执行 set http_proxy="" 以及 set https_proxy (注意,这只针对当前的CMD窗口,不改变系统环境变量以及其他的CMD窗口以及后来新打开的CMD窗口)
然后再次执行pip install pymysql,报错为:
C:\WINDOWS\system32>pip install pymysql
Looking in indexes: http://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.', NewConnectionError('<pip._vendor.urllib3.connection.HTTPConnection object at 0x0000014E15A1B970>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))': http://mirrors.aliyun.com/pypi/simple/pymysql/
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.HTTPConnection object at 0x0000014E15A1BC70>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))': http://mirrors.aliyun.com/pypi/simple/pymysql/
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.HTTPConnection object at 0x0000014E15A1BEE0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))': http://mirrors.aliyun.com/pypi/simple/pymysql/
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.HTTPConnection object at 0x0000014E15A6C1F0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))': http://mirrors.aliyun.com/pypi/simple/pymysql/
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.HTTPConnection object at 0x0000014E15A6C430>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))': http://mirrors.aliyun.com/pypi/simple/pymysql/
ERROR: Could not find a version that satisfies the requirement pymysql (from versions: none)
ERROR: No matching distribution found for pymysql
尝试关闭专用网络,并没有作用。
最后解决方法:
pip config list
C:\WINDOWS\system32>pip config list
global.index-url='http://mirrors.aliyun.com/pypi/simple/'
install.trusted-host='mirrors.aliyun.com'
ping mirrors.aliyun.com
C:\WINDOWS\system32>ping mirrors.aliyun.com
Pinging mirrors.aliyun.com.w.alikunlun.com [112.132.37.201] with 32 bytes of data:
Reply from 112.132.37.201: bytes=32 time=11ms TTL=55
Ping statistics for 112.132.37.201:
因此可以用:
pip install pymysql --proxy 112.132.37.201:80
对了,对于最上面的“ERROR: Could not install packages due to an OSError: Missing dependencies for SOCKS support.”问题,安装pysock即可解决,后续就不用再set http_proxy=""了。
pip install pysocks --proxy 112.132.37.201:80
!!!注意,以上是pysocks,不是pysock,这是两个不同的库
附:linux平台只需要unset http_proxy以及unset https_proxy即可。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。