deepin python3.8 安装三方库请求ssl的报错和openssl编译升级 - Go语言中文社区

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

  完成之后测试:

 

版权声明:本文来源博客园,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://www.cnblogs.com/muxizZ/p/13408895.html
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2021-06-12 17:18:26
  • 阅读 ( 740 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢