ubuntu 16.04 python 3.x 安裝OpenSSL
阿新 • • 發佈:2018-04-29
不出 圖片 下載 1.0 ins python3.6 url 進入目錄 set
錯誤提示:
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
沒有報錯就已經成功了!
ubuntu 16.04 python 3.x 安裝OpenSSL