【问题标题】:Why i get errors while Installing Python modules?为什么在安装 Python 模块时出现错误?
【发布时间】:2022-01-17 09:53:17
【问题描述】:

我正在使用:

  1. Python 3.10.1
  2. 点 21.2.4
  3. 虚拟环境中的 Python 项目

我的问题: 每次我尝试安装任何软件包(例如 opencv)时,都会出现以下错误:

(einstieg) C:\Users\User\Python\pyproj>pip install python-ldap
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by
 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:997)'))': /simple/python-ldap/ 
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by
 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:997)'))': /simple/python-ldap/ 
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by
 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:997)'))': /simple/python-ldap/ 
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by
 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:997)'))': /simple/python-ldap/ 
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by
 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:997)'))': /simple/python-ldap/ 
Could not fetch URL https://pypi.org/simple/python-ldap/: 
There was a problem confirming the ssl certificate: 
HTTPSConnectionPool(host='pypi.org', port=443): 
Max retries exceeded with url: /simple/python-ldap/ 
(Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:997)'))) - skipping 

ERROR: Could not find a version that satisfies the requirement python-ldap (from versions: none) 
ERROR: No matching distribution found for python-ldap 
Could not fetch URL https://pypi.org/simple/pip/: 
There was a problem confirming the ssl certificate:
HTTPSConnectionPool(host='pypi.org', port=443): 
Max retries exceeded with url: /simple/pip/ 
(Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:997)'))) - skipping

我尝试了一些我发现的受信任主机提示,但没有任何效果。 有人知道我的问题出在哪里吗?

【问题讨论】:

  • 您是否在需要代理的网络上和/或您是否配置了代理?
  • 是的代理,我需要下载包...
  • pip 有代理配置,我相信;正确设置应该会有所帮助,您只需执行一次(而不是总是手动下载包)

标签: python pip


【解决方案1】:

此问题与 SSL 证书有关。尝试将其粘贴到 CMD 中:

python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip

如果这不起作用,试试这个:

pip install requests==2.18.4 --user --trusted-host=pypi.python.org --trusted-host=pypi.org --trusted-host=files.pythonhosted.org

如果您之前安装了Fiddler,请将其卸载,这可能是问题的原因。

最后,如果这些都不起作用,那么您需要直接从 wheel 下载文件。这意味着首先你要在你的电脑上下载这个包,然后写pip install your-package.whl。

您可以在网上轻松找到 OpenCV 和其他包的 .whl 文件。

【讨论】:

  • 嗨,我是 python 新手,仅作为一般信息:) 我尝试了两个 CMD 命令,但都没有工作......所以我需要从“wheel”下载包......那么什么是轮子,我在哪里可以找到它? :)
  • 你可以从包的网站上获取,如果有的话,或者如果你在谷歌上搜索,opencv-python .whl 或任何包。手动下载 .whl 文件 a.k.a wheel file 应该可以解决大部分下载问题
  • 我发现了问题:我需要正确的模块路径。就是这样……
猜你喜欢
  • 1970-01-01
  • 2014-05-07
  • 1970-01-01
  • 1970-01-01
  • 2016-11-02
  • 1970-01-01
  • 2022-01-25
  • 2018-06-06
  • 2013-07-28
相关资源
最近更新 更多