pip 无法安装任何包

新手上路,请多包涵

你好,大约 2 周前,我开始无法下载 python 包,甚至无法访问在 chrome 和 firefox 上“无法访问”的 pypi 网站。

当我尝试下载一个包时,它给了我这个:

 $ python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
Collecting numpy
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/numpy/
  Could not find a version that satisfies the requirement numpy (from versions: )
No matching distribution found for numpy

我不知道为什么会这样,我没有在我的电脑上做任何改变,它只是有一天开始在我的两台电脑上做这个,我不明白。有人知道为什么会这样吗?我搜索了几个小时,但找不到任何东西来纠正这个错误。

我尝试过的: - 卸载每个 python 程序并重新安装 - 检查我的驱动程序(你永远不知道) - 停用任何代理 - 禁用我的防火墙

操作系统:Windows 10

原文由 Shraneid 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.3k
2 个回答

因此,对于寻找解决方案的任何人,我发现这可能不是最佳的,但至少它有效,而不是 pip install package 使用这个命令

python.exe -m pip install package --proxy="proxy:port"

您可以在此处找到大量免费代理: https ://free-proxy-list.net/(请注意,并非所有代理都有效,您可能想尝试多个才能获得有效代理)

因此,例如您可以使用: python.exe -m pip install numpy --proxy="179.185.199.195:8080"

原文由 Shraneid 发布,翻译遵循 CC BY-SA 4.0 许可协议

使用上一个答案中的代理可以暂时解决问题 - 如果您发现没有超时的代理,但它不能解决问题,并且在大多数情况下使用代理会影响您的下载速度。

我发现您需要调查您的 Python 解释器位置并确保 venv 不会导致问题。

例如,如果 setuptools 不会更新,那么很可能您的代码或项目的一部分已经在持续使用 setuptools - 禁止它更新 - 其他包需要安装新版本的 setuptools。

由于某种原因,这会导致“ConnectionResetError:现有连接被远程主机强行关闭”出现在大多数软件包中,如 tensorflow、keras、pandas 等。

在另一个空位置重新创建您的 venv 将重置所有包

要在 Pycharm 中执行此操作:

 File -> Settings
Project: -> Project Interpreter
Project Interpreter -> drop down list -> show all

Remove your current Python Interpreter location
Add New Environment

然后你将被要求为你的项目放置一个位置:在这里使用一个新位置将解决包安装的 [Win10054] ConnectionResetError。

基本解释器:指向您的 python.exe 位置(通常默认:C:\Users\UserProfile\AppData\Local\Programs\Python\PythonXX\python.exe 并将 XX 替换为您当前的版本,将 UserProfile 替换为您的配置文件)

最重要的是:因为你已经设置了一个新位置,所以首先安装 setuptools,如果已经安装,那么先升级它。之后,您可以将代码迁移到新的 venv,并且所有新包都应该可以正常工作而不会出现任何 connectionResetErrors。

原文由 Donovan Maree 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
logo
Stack Overflow 翻译
子站问答
访问
宣传栏