首页 > 解决方案 > pip raises ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

问题描述

当我使用 pip 安装软件包时,由于 ProtocolError,所有安装都失败了。我的 python 和 pip 是由 pyenv 安装的。这是错误消息:

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/requests/
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/requests/
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/requests/
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/requests/
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/requests/
ERROR: Could not find a version that satisfies the requirement requests (from versions: none)
ERROR: No matching distribution found for requests

这是详细模式打开的消息:

Using pip 21.1.3 from /Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pip (python 3.9)
Non-user install because site-packages writeable
Created temporary directory: /private/var/folders/yg/d8p9gpw91hd21m1cpps281z0000wy0/T/pip-ephem-wheel-cache-r_q5g7cd
Created temporary directory: /private/var/folders/yg/d8p9gpw91hd21m1cpps281z0000wy0/T/pip-req-tracker-626eaa4_
Initialized build tracking at /private/var/folders/yg/d8p9gpw91hd21m1cpps281z0000wy0/T/pip-req-tracker-626eaa4_
Created build tracker: /private/var/folders/yg/d8p9gpw91hd21m1cpps281z0000wy0/T/pip-req-tracker-626eaa4_
Entered build tracker: /private/var/folders/yg/d8p9gpw91hd21m1cpps281z0000wy0/T/pip-req-tracker-626eaa4_
Created temporary directory: /private/var/folders/yg/d8p9gpw91hd21m1cpps281z0000wy0/T/pip-install-9zh25v9s
1 location(s) to search for versions of requests:
* https://pypi.org/simple/requests/
Fetching project page and analyzing links: https://pypi.org/simple/requests/
Getting page https://pypi.org/simple/requests/
Found index url https://pypi.org/simple
Looking up "https://pypi.org/simple/requests/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
Incremented Retry for (url='/simple/requests/'): Retry(total=4, connect=None, read=None, redirect=None, status=None)
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/requests/
Starting new HTTPS connection (2): pypi.org:443
Incremented Retry for (url='/simple/requests/'): Retry(total=3, connect=None, read=None, redirect=None, status=None)
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/requests/
Starting new HTTPS connection (3): pypi.org:443
Incremented Retry for (url='/simple/requests/'): Retry(total=2, connect=None, read=None, redirect=None, status=None)
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/requests/
Starting new HTTPS connection (4): pypi.org:443
Incremented Retry for (url='/simple/requests/'): Retry(total=1, connect=None, read=None, redirect=None, status=None)
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/requests/
Starting new HTTPS connection (5): pypi.org:443
Incremented Retry for (url='/simple/requests/'): Retry(total=0, connect=None, read=None, redirect=None, status=None)
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/requests/
Starting new HTTPS connection (6): pypi.org:443
Could not fetch URL https://pypi.org/simple/requests/: connection error: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/requests/ (Caused by ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))) - skipping
Skipping link: not a file: https://pypi.org/simple/requests/
Given no hashes to check 0 links for project 'requests': discarding no candidates
ERROR: Could not find a version that satisfies the requirement requests (from versions: none)
ERROR: No matching distribution found for requests
Exception information:
Traceback (most recent call last):
  File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 341, in resolve
    name, crit = self._merge_into_criterion(r, parent=None)
  File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 173, in _merge_into_criterion
    raise RequirementsConflicted(criterion)
pip._vendor.resolvelib.resolvers.RequirementsConflicted: Requirements conflict: SpecifierRequirement('requests')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 127, in resolve
    result = self._result = resolver.resolve(
  File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 473, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 343, in resolve
    raise ResolutionImpossible(e.criterion.information)
pip._vendor.resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=SpecifierRequirement('requests'), parent=None)]

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 180, in _main
    status = self.run(options, args)
  File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 318, in run
    requirement_set = resolver.resolve(
  File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 136, in resolve
    raise error from e
pip._internal.exceptions.DistributionNotFound: No matching distribution found for requests
1 location(s) to search for versions of pip:
* https://pypi.org/simple/pip/
Fetching project page and analyzing links: https://pypi.org/simple/pip/
Getting page https://pypi.org/simple/pip/
Found index url https://pypi.org/simple
Looking up "https://pypi.org/simple/pip/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
Could not fetch URL https://pypi.org/simple/pip/: connection error: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))) - skipping
Skipping link: not a file: https://pypi.org/simple/pip/
Given no hashes to check 0 links for project 'pip': discarding no candidates
Removed build tracker: '/private/var/folders/yg/d8p9gpw91hd21m1cpps281z0000wy0/T/pip-req-tracker-626eaa4_'

该错误似乎是 urllib3 错误,并且缺少某些内容。关于缺少什么的任何想法?欣赏任何信息!

仅供参考,我已尝试重新安装 python,但它仍然无法正常工作。我也尝试了由 anaconda 安装的 python,但它的 pip 也不起作用。只有系统内置的 pip 有效。

标签: pythonpip

解决方案


推荐阅读