deepin python3.8 安装三方库请求ssl的报错和openssl编译升级

问题:

  在安装完python3.8后,安装第三方库出现报错:Can't connect to HTTPS URL because the SSL module is not available. - skipping

   查看了自身的openssl版本,1.1.1算是比较新的了,那么问题就是python3.8在安装的时候没有找到openssl.而自带的openssl却找不到真正的路径,所以需要重新安装到指定目录。

下载安装openssl: 

 1 # 备份老版本的openssl
 2 which openssl
 3 /usr/bin/openssl
 4 mv /usr/bin/openssl /usr/bin/openssl.old
 5 rm -rf /etc/ssl/
 6 
 7 # 安装新版本openssl
 8 wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
 9 tar -zxvf openssl-1.1.1g.tar.gz && cd openssl-1.1.1g
10 ./config --prefix=/usr/local/openssl
11 make && make install
12 ln -s /usr/local/openssl/bin/openssl  /usr/local/bin/openssl
13 cp -r /usr/local/bin/openssl /usr/bin/
14 openssl version -a

重新编译python3.8:

  进入python3的源码目录:

  vi Modules/Setup

  按/查找_ssl,将如下部分代码的注释#去掉,wq保存,配置一定要是自己的openssl执行文件路径(默认是/usr/local/ssl,我这里修改了) 

1 # Socket module helper for socket(2)
2 _socket socketmodule.c
3 
4 # Socket module helper for SSL support; you must comment out the other
5 # socket line above, and possibly edit the SSL variable:
6 SSL=/usr/local/openssl
7 _ssl _ssl.c \
8         -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
9         -L$(SSL)/lib -lssl -lcrypto

  改完之后再进行编译安装:

1 ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
2 make && make install

  完成之后测试:

 

posted @ 2020-07-31 11:53  木兮zZ  阅读(1653)  评论(0编辑  收藏  举报