python3.7 ImportError: No module named _ssl solution

The author centos6.5installation python3.7encountered this problem after installed, execute python3.7the command line, import sslan error occurs ImportError: No module named _ssl. The error is detected at pip installthe time will be reportedpip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

The Internet to find a lot of information, verified, modified before compiling pythonthe source code the way (Modules/Setup.dist)is not effective. Upgrade opensslto 1.1.xlater versions are valid.

Resolve as follows:

First, download compile and install openssl

openssl official Download: https://www.openssl.org/source/

I then installed version is: openssl-1.1.1c


tar xf openssl-1.1.1c.tar.gz
cd openssl-1.1.1c
./config --prefix=/usr/local/openssl-1.1.1c
make
make install

Second, configure openssl shared libraries

'''新建文件'''
vim /etc/ld.so.conf.d/openssl.conf

'''填入如下内容'''
/usr/local/openssl-1.1.1c/lib/

'''保存'''

'''更新共享库'''
ldconfig

'''检验 openssl-1.1.1 是否已加入共享库'''
ldconfig -v | grep ssl

/usr/local/openssl-1.1.1c/lib:
    libssl.so.1.1 -> libssl.so.1.1    '''有这个表示加成功了'''
    libssl3.so -> libssl3.so
    libssl.so.10 -> libssl.so.1.0.1e

Third, install python3.7

cd /usr/local/python3.7/
./configure --prefix=/usr/local/python3.7 --with-openssl=/usr/local/openssl-1.1.1c
make && make install

Guess you like

Origin blog.51cto.com/tchuairen/2435472