当前位置: 移动技术网 > IT编程>脚本编程>Python > ubuntu 16.04 python 3.x 安装OpenSSL

ubuntu 16.04 python 3.x 安装OpenSSL

2018年04月30日  | 移动技术网IT编程  | 我要评论

交通拥堵,杨亿巧对,风云2国语高清

错误提示:

Can't connect to HTTPS URL because the SSL module is not available.

连接HTTPS时,提示SSL不可用

测试

# 进入python
$ python3  # or python3.6
# 导入SSL模块
>>> import ssl

如果出现下面提示,则Python不支持SSL。

错误提示

解决方案

下载文件

  • OpenSSL

  • $ wget http://www.openssl.org/source/openssl-1.0.2e.tar.gz

  • Python3.6 - 选择需要的版本

  • $wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz

安装

OpenSSL

# 解压文件
tar xvzf openssl-1.0.2e.tar.gz
# 进入目录
$ ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
$ make
$ make test
$ sudo make install

Python

进入目录
#解压
$ tar xvzf Python-3.6.2.tgz
$ cd Python-3.6.2
修改安装配置

使用VIM打开文件Modules/Setup.dist文件,搜索SSL,取消四行注释

$ vim Modules/Setup.dist

修改配置

开始安装

完成上面操作就可以安装了,执行下面3行代码

$ ./configure
$ make
$ sudo make install

完成!

不出意外已经安装完成,下面检测一下。

  • 进入python

$ python3

  • 导入SSL模块

>>> import ssl

 导入成功

没有报错就已经成功了!

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网