人类的孤独像是一种与生俱来的残疾。

Ubuntu下“pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.”

Python/Shell smallfish 7118℃

Ubuntu默认会自带python2.7,但现在发行版本已经到3.6.2了,3.7也正处于开发当中。而ubuntu上的python3只到3.2,所以需要手动安装3.6.2。

我第一次也是按部就班地从python官网下载源码,然后配置->编译->安装。然而今天使用pip安装python包时出现如题所述的问题。

提示已经很明显了,python没有开启ssl。在网上找了一圈,都是CentOS/ReadHat的解决方案,Ubuntu下没找到。最后还是在Stack Overflow找到了答案,摘抄如下:

sudo apt-get install python3-dev libffi-dev libssl-dev
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz  
tar xvf Python-3.6.0.tgz
cd Python-3.6.0
./configure --enable-optimizations  
make -j8  
sudo make altinstall
python3.6

作者使用的是3.6.0版本,我是3.6.2实测有效。

几点说明:

1.安装python前先安装三个依赖包(第一行);

2.配置使用--enable-optimizations参数;

3.编译使用-j8参数加速make;

4.安装使用make altinstall避免覆盖原版本。

以上,感谢原作者,附上链接:https://stackoverflow.com/questions/41489439/pip3-installs-inside-virtual-environment-with-python3-6-failing-due-to-ssl-modul。

 

转载请注明:OpenMind » Ubuntu下“pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.”

喜欢 (19)