错误描述
cmd输出的异常信息
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Collecting selenium
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002BFE5592EF0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/selenium/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002BFE5592940>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/selenium/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002BFE55928D0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/selenium/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002BFE5592AC8>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/selenium/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002BFE5737BA8>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /simple/selenium/
Could not find a version that satisfies the requirement selenium (from versions: )
No matching distribution found for selenium
pycharm安装库失败
错因分析
由于GFW的存在,当我们在使用pip下载安装某个库的时候,会遇到莫名其妙的网络问题,比如我初学就死活安装不上selenium库。
解决办法
临时修改
在使用pip的时候加参数-i,如下:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 库名
永久修改
Linux下,修改~/.pip/pip.conf(或者创建一个),将index-url变量修改为所要更换的源地址:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
windows下
1.在user目录中创建一个pip目录,如C:\Users\xx\pip
2.新建文件pip.ini
写入如下内容:
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
trusted-host = mirrors.tsinghua.com
我在这用的是清华的镜像,附上一些其他好用的供大家选择