There are a lot of articles on the Internet about how to solve the failure of Python3.7 import _SSL module, but most of the actual operation is not successful. The following method can be used in a practical test.
First, install dependencies
OpenSSL or Libressl (either optional) is required to install the SSL module. OpenSSL is installed in version 1.0.1, which does not meet the requirements of Python3.7. The version requirements for the SSL library are as follows:
openssl > = 1.0.2 libressl & gt; = 2.6.4
My working environment:
14.04 Python3.7.3 Ubutun download link: https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
Download and install Libressl
Website: https://www.libressl.org/, download link: https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.9.1.tar.gz./config – prefix =/usr/local/SSL make sudo make intallmv/usr/bin/openssl/usr/bin/openssl. Bak (if not installed SSL before, /usr/include/openssl.bak /usr/include/openssl.bak This step can be skipped) ln -s/usr/local/SSL/bin/openssl/usr/bin/openssl ln -s/usr/local/SSL/include/openssl/usr/include/openssl in/etc/ld. So. Conf., d directory to create libressl – 2.9.1. Conf file, add/usr/local/SSL/libsudo ldconfig
Install Python3.7
Configure environment variables
Export LDFLAGS = “-l/usr/local/SSL/lib”
export CPPFLAGS = “-i/usr/local/SSL/include”
export PKG_CONFIG_PATH = “/ usr/local/SSL/lib/pkgconfig”
Unzip the Python installation package and execute the configure file:
./configure — enable – Shared
Check that the SSL configuration is working

Verifies that the SSL module was successfully installed in /usr/local/bin/python3.7

3. Other errors
Failed to compile the SSL module

Solutions:
Go to the libressl compilation directory libressl-2.9.1
Sudo cp SSL/libs/libssl. So the 47.0.5 – gnu/Linux/lib/x86_64 –
sudo cp crypto/libs/libcrypto. So the 45.0.4/lib/x86_64 – – the gnu/Linux
Sudo ln-s /lib/x86_64-linux-gnu/libcrypto.so.47.0.5 /lib/x86_64-linux-gnu/libcrypto.so.47
sudo ln-s /lib/x86_64-linux-gnu/libcrypto.so.45.0.4 /lib/x86_64-linux-gnu/libcrypto.so.45
recompile
Failed to compile the _ctypes module

Sudo apt-get install libffi-dev, install libffi-dev, install libffi-dev
First, install dependencies
OpenSSL or Libressl (either optional) is required to install the SSL module. OpenSSL is installed in version 1.0.1, which does not meet the requirements of Python3.7. The version requirements for the SSL library are as follows:
openssl > = 1.0.2 libressl & gt; = 2.6.4
My working environment:
14.04 Python3.7.3 Ubutun download link: https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
Download and install Libressl
Website: https://www.libressl.org/, download link: https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.9.1.tar.gz./config – prefix =/usr/local/SSL make sudo make intallmv/usr/bin/openssl/usr/bin/openssl. Bak (if not installed SSL before, /usr/include/openssl.bak /usr/include/openssl.bak This step can be skipped) ln -s/usr/local/SSL/bin/openssl/usr/bin/openssl ln -s/usr/local/SSL/include/openssl/usr/include/openssl in/etc/ld. So. Conf., d directory to create libressl – 2.9.1. Conf file, add/usr/local/SSL/libsudo ldconfig
Install Python3.7
Configure environment variables
Export LDFLAGS = “-l/usr/local/SSL/lib”
export CPPFLAGS = “-i/usr/local/SSL/include”
export PKG_CONFIG_PATH = “/ usr/local/SSL/lib/pkgconfig”
Unzip the Python installation package and execute the configure file:
./configure — enable – Shared
Check that the SSL configuration is working

Verifies that the SSL module was successfully installed in /usr/local/bin/python3.7

3. Other errors
Failed to compile the SSL module

Solutions:
Go to the libressl compilation directory libressl-2.9.1
Sudo cp SSL/libs/libssl. So the 47.0.5 – gnu/Linux/lib/x86_64 –
sudo cp crypto/libs/libcrypto. So the 45.0.4/lib/x86_64 – – the gnu/Linux
Sudo ln-s /lib/x86_64-linux-gnu/libcrypto.so.47.0.5 /lib/x86_64-linux-gnu/libcrypto.so.47
sudo ln-s /lib/x86_64-linux-gnu/libcrypto.so.45.0.4 /lib/x86_64-linux-gnu/libcrypto.so.45
recompile
Failed to compile the _ctypes module

Sudo apt-get install libffi-dev, install libffi-dev, install libffi-dev
Read More:
- Solve fatal error: ‘FFI. H’ file not found
- Raspberry pie upgrade to Python 3.7.3
- Installation and unloading of Python module
- Linux update Python method and error handling
- Git solves the problem of failed: http request failed
- [Caffe] fatal error: hdf5.h: No such file or directory error solution
- Installing open CV under Linux system
- Compiling the pi_kernel source code appears: fatal error: openssl/opensslv.h: No such file or directory
- Installing GCC reduced version GCC 4.4.6 under Linux
- Solve the problem of prompt couldn’t find path to unrear library after installing unrear in Python
- Linux CentOS installing protobuf
- SSL handshake failed: SSL error: illegal key usage detected in the certificate
- How to install cuda10.01in Ubuntu18.04
- CentOS solves the problem of modulenotfounderror when salt calls python3 script remotely, and solves the problem that PIP3 module cannot be shared by different users
- Error in installing cryptograph failed building wheel for cryptography
- .. ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make[2]: ***
- Installing opencv and Linux Makefile:160 : recipe for target ‘all’ failed problem resolution
- Failed building wheel for psycopg2
- Pysot installation and model testing
- Centos7 quick installation of docker and configuration of image acceleration