centos7 install python3.6 solve the above problem openssl

In centos7 system, install the original way to install python3.6, when library use request, the system will prompt

报错信息: Can't connect to HTTPS URL because the SSL module is not available

problem analysis:

Viewing System openssl version:

[root@zj ~]# openssl version -a
OpenSSL 1.0.1e
Baidu after the discovery ssl version must be version 1.1 or 1.0.2, if later, or libressl after 2.6.4 is installed.
I began to explore the road:
method one:
1. Download openssl-1.0.2h.tar.gz
wget https://www.openssl.org/source/openssl-1.0.2h.tar.gz
2, updated zlib
yum install -y zlib
3, extract the installation
tar zxf openssl-1.0.2h.tar.gz
cd openssl-1.0.2h
./config shared zlib
make && make install
 
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
echo “/usr/local/ssl/lib” >> /etc/ld.so.conf
ldconfig -v
 
4, to see if the upgrade is successful
[root@zj ~]# openssl version -a
OpenSSL 1.0.2h 3 May 2016

 

Reinstall the python, coupled with the -with-ssl

./configure –prefix=/usr/local/Python3.71 –with-ssl

make&make install

I began to check:

 

 Import module is not being given to ssl

Method Two:

1. compile and install OpenSSL 1.0.2j version and re-configuration environment variable

Download OpenSSL source package :( performed under / usr / local / python3)
wget http://www.openssl.org/source/openssl-1.0.2j.tar.gz

Decompress, compile and install:
tar -zxvf OpenSSL-1.0.2j.tar.gz
cd OpenSSL-1.0.2j

# Modify translation parameters, no-zlib not need zlib 
./config --prefix = / usr / local / to python3 / OpenSSL-NO-zlib 1.0.2j

make && make install

2. Re-compile and install python3.6.2

tar -zxvf Python-3.6.2.tgz
cd Python-3.6.2
./configure --prefix=/usr/local/python3

After this step, do not worry run make. To modify the source directory Python-3.6.2 / Modules / Setup file:

[root@localhost ~]# vim Modules/Setup

# Socket module helper for socket(2)
#_socket socketmodule.c

SSL Module Helper for the Socket # Support; the Comment you the MUST OUT at The OTHER
# socket Line above, and Possibly Edit variable at The SSL:
SSL = / usr / local / Lab / OpenSSL-1.0.2j / # uncomment this line, and the original / usr / local / ssl openssl directory changed our newly installed: /usr/local/python3/openssl-1.0.2j/
_ssl _ssl.c \ # uncomment this line
-DUSE_SSL -I $ (SSL) / include -I $ (SSL) / include / openssl \ # uncomment this line
-L $ (SSL) / lib -lssl -lcrypto # uncomment this line

Finally, re-compile and install python3:

make& make install 

Again lead pack, successfully installed

 

 

Into the pit is completed.

Reference documents: http://www.yueguangzu.net/?p=1677

       https://blog.csdn.net/reblue520/article/details/94072018

       https://www.jb51.net/article/166688.htm

       

 

Guess you like

Origin www.cnblogs.com/fcc-123/p/12021104.html
Recommended