Error message:
Can't connect to HTTPS URL because the SSL module is not available.
When connecting to HTTPS, it prompts that SSL is unavailable
test
# 进入python
$ python3 # or python3.6
# 导入SSL模块
>>> import ssl
If the following prompt appears, Python does not support SSL.
download file
OpenSSL
$ wget http://www.openssl.org/source/openssl-1.0.2e.tar.gz
Python3.6 - select the desired version
$wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
Install
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
enter the directory
#解压
$ tar xvzf Python-3.6.2.tgz
$ cd Python-3.6.2
Modify installation configuration
Open the file file with VIM
Modules/Setup.dist
, search for SSL, uncomment the four lines
$ vim Modules/Setup.dist
start installation
After completing the above operation, you can install it, execute the following 3 lines of code
$ ./configure
$ make
$ sudo make install
Finish!
Not surprisingly, the installation has been completed, let's check it below.
- enter python
$ python3
- Import the SSL module
>>> import ssl
It has succeeded without any errors!