繁体   English   中英

由于证书错误,pip3 无法为 Python3.8 安装

[英]pip3 can't install for Python3.8 due to certificate errors

让我先说一下,这个问题在 Stack Overflow 上出现了很多。 我已经阅读了许多答案并尝试了许多解决方案,但都没有解决我的问题。 但首先,问题是:

我尝试过的一些事情(并非详尽无遗):

pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name>
python3 -m pip install <package_name>
pip3 install <package name>

每次都或多或少相同的错误:

Defaulting to user installation because normal site-packages is not writeable
Could not fetch URL https://pypi.org/simple/venv/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/venv/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement venv (from versions: none)
ERROR: No matching distribution found for venv
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

我在 WSL2 Ubuntu 20.04 上运行它。 我感谢任何想法或建议。 我还完全重新安装了 python,尝试了不同版本的 python,重新安装了 pip,尝试了不同版本的 Z62AD1C2、2A46C5298DDC3

编辑: type -a python3 python3.8 , python3 , import ssl类型的结果

python3 is /usr/local/bin/python3
python3 is /usr/bin/python3
python3 is /bin/python3
python3.8 is /usr/local/bin/python3.8
python3.8 is /usr/bin/python3.8
python3.8 is /bin/python3.8
#@#:/usr/local/lib$ python3
Python 3.8.6 (default, Nov 19 2020, 14:27:22)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'

问题是您在/usr/local/bin中有“本地”安装的python3python3.8 ,它们显然没有ssl模块。 它们在PATH中更高,因此它们覆盖了/usr/bin中的系统安装

因此,与此同时,您应该能够像这样使用pip

/usr/bin/python3 -m pip ...

最终,您可能希望删除本地安装。 但是,你没有提到你是如何安装它们的,所以我没有更多的细节。 可能,您从源代码构建然后确实make altinstall

对于其他 pip 安装,我收到此错误。

尝试使用-m pip3 install <package_name>

而不是-m pip install <package_name>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM