python3.7.2 ssl版本过低导致pip无法使用的问题

环境:系统是centos6.6,python:python3.7.2

问题:安装好python3、pip后,在通过pip install xx 安装模块时,发现无法安装的问题,提示版本太低,系统默认的是openssl1.0.1,需要1.0.2或者libressl。在网上也搜了各种资料,试了各种方式,终于给试出来了,现总结如下,希望帮到遇到此问题的同学。

错误提示:

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

Could not fetch URL https:*******: There was a problem confirming the ssl certificate: 
Can't connect to HTTPS URL because the SSL module is not available. - skipping

 

解决:

  安装libressl代替openssl-devel 

   下载libress-2.8.3,wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.8.3.tar.gz

   解压,安装:

tar -zxvf libressl-2.8.3.tar.gz
cd libressl-2.8.3
./config –prefix=/usr/local/ssl 
make 
make intall

#原来的备份
mv /usr/bin/openssl /usr/bin/openssl.bak 
mv /usr/include/openssl /usr/include/openssl.bak 
#建立软链
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl 
ln -s /usr/local/ssl/include/openssl /usr/include/openssl

cd /etc/ld.so.conf.d 
#新建文件 libressl-2.8.3.conf,增加以下内容
/usr/local/ssl/lib
ldconfig -v #重新加载库文件

#验证,如果出来LibreSSL 2.8.3,说明成功
openssl version 

 

然后再进行python3的安装,这样基本上就不会出现上面的问题了

注意:在编译python的环境前,需要做以下环境变量配置:

  export LDFLAGS="-L/usr/local/ssl/lib" 
  export CPPFLAGS="-I/usr/local/ssl/include"
  export PKG_CONFIG_PATH="/usr/local/ssl/lib/pkgconfig"

接下来就可以好好地安装python了。。。

    

posted @ 2019-01-10 17:21  bookwed  阅读(2740)  评论(0编辑  收藏  举报