#问题描述#
使用pip安装模块时总是失败并显示无法连接:
pip3 install selenium --log aa
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'))': /simple/selenium/
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'))': /simple/selenium/
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'))': /simple/selenium/
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'))': /simple/selenium/
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'))': /simple/selenium/
ERROR: Could not find a version that satisfies the requirement selenium (from versions: none)
ERROR: No matching distribution found for selenium
网上也有很多解决方案,比如:
.升级pip
.升级python
.设置其他源
.修改pip_ini配置文件
这些都不能解决该问题,但错误信息中以及日志中都没有指向很明确的提示
#问题调查#
pip search selenium
ERROR: Exception:
Traceback (most recent call last):
File "C:\Program Files\Python3\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 714, in urlopen
httplib_response = self._make_request(
File "C:\Program Files\Python3\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 403, in _make_request
self._validate_conn(conn)
File "C:\Program Files\Python3\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 1053, in _validate_conn
conn.connect()
File "C:\Program Files\Python3\lib\site-packages\pip\_vendor\urllib3\connection.py", line 400, in connect
self.ssl_context = create_urllib3_context(
File "C:\Program Files\Python3\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py", line 350, in create_urllib3_context
context.keylog_filename = sslkeylogfile
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\keyfile\\tempsslkey.log'
During handling of the above exception, another exception occurred:
最后发现当执行search操作时,提示语就很明确,原来是因为缺少tempsslkey.log文件导致https的源无法连接
#问题解决#
在提示语指明的路径中新建缺少的文件,重新执行安装操作,一切正常
pip install命令的提示语不明确,可以加上--log选项输出更加的详细日志,如果提示语依然不明确,可以切换其他选项,直到找到明确提示语为止