【发布时间】:2021-02-23 22:11:45
【问题描述】:
让我先说一下,这个问题在 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,尝试了不同版本的 pip,以及其他一些事情。
编辑:
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'
【问题讨论】:
-
python3 -m ensurepip -
您是如何安装/重新安装 Python 的?如果您从源代码构建它,看起来可能会发生这种情况。见this answer
-
@PedroLobito ensurepip 工作并表示满足所有条件。
-
@wjandrea 我现在正在尝试回答这个问题,但在 /usr/local/lib/Python3.8 中找不到 ./configure 文件。那是我应该期待的吗?
-
@wjandrea 我将结果添加到我的原始答案中,因为评论有点多。
标签: python python-3.x linux pip