The author centos6.5
installation python3.7
encountered this problem after installed, execute python3.7
the command line, import ssl
an error occurs ImportError: No module named _ssl
. The error is detected at pip install
the 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 python
the source code the way (Modules/Setup.dist)
is not effective. Upgrade openssl
to 1.1.x
later 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