最近我遇到了 Ubuntu 18.04 pip3无法正常工作的问题:
:~$ pip3 install jinja2
Traceback (most recent call last):
File "/home/redra/.local/bin/pip3", line 7, in <module>
from pip import main
ModuleNotFoundError: No module named 'pip'
然后我尝试重新安装 pip3,似乎是由于它并面临另一个问题:
:~$ sudo -H python3 get-pip.py
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting pip
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
我想它卡住了...由于 pip3 错误,我无法安装 openssl,并且由于 openssl 无法安装新的 pip3 ...似乎是循环(
有什么建议吗?有没有人面临同样的问题?
这可能是因为编译 python 时所需的
openssl
二进制文件不存在,来解决这个问题从: https ://www.openssl.org/source/ 下载 openssl(tar.gz 就可以了)
在文件夹中解压 SSL 源
转到文件夹并运行以下命令以制作 openssl
./configure && make && sudo make install
最后 - 重做 Python 编译(配置、制作、安装),观察 ssl 库现在编译成 Python,因为它出现在 Python 编译过程正在寻找的标准位置。