centos6.8 installation python3.7.3 error Can not connect to HTTPS URL because the SSL module is not available to solve the problem

Environment: CentOS Release 6.8 (Final)


# Compiler directly python3.7 when using pip3 installation dependent error:

Can't connect to HTTPS URL because the SSL module is not available.


Solution:

1 . Compile install OpenSSL 1.0 .2j version and re-configuration environment variable

Download OpenSSL source package:
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
./config --prefix=/usr/local/lab/openssl-1.0.2j shared zlib
make && make install


2 . Compiler installation Python3, using a custom OpenSSL

Download Python3 . 7 .3 Source Package:

wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz

Decompress, compile and install:

tar -zxvf Python-3.7.3.tgz
cd Python-3.7.3
./configure --prefix=/usr/local/python373

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

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

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL = / usr / local / Lab / openssl- 1.0 .2j / # uncomment this line, and the original / usr / local / ssl changed our newly installed openssl directory: / usr / local / lab / openssl- 1.0 .2j /
_ssl _ssl.c \ # Uncomment this line
The -I $ -DUSE_SSL (SSL) / the include the -I $ (SSL) / the include / OpenSSL \ # Uncomment this line
 -L $ (SSL) / lib -lssl - lcrypto # Uncomment this line

# The crypt module is now disabled by default because it breaks builds
# on many systems (where -lcrypt is needed), e.g. Linux (I believe).

#_crypt _cryptmodule.c # -lcrypt    # crypt(3); needs -lcrypt on some systems


After modifications are complete, we need to create two points soft link dynamic link library file:
ln -s /usr/local/lab/openssl-1.0.2j/lib/libssl.so.1.0.0 /usr/lib64/libssl.so.1.0.0
ln -s /usr/local/lab/openssl-1.0.2j/lib/libcrypto.so.1.0.0 /usr/lib64/libcrypto.so.1.0.0


Finally, compile and install:
make && make install

# Create a soft link
ln -s /usr/local/python373/bin/pip3 /usr/local/bin/pip3
ln -s /usr/local/python373/bin/python3 /usr/local/bin/python3

# Install the software continues to error:
[root@srv3:/usr/local]# pip3 install requests
Collecting requests
/usr/local/python373/bin/python3.7: symbol lookup error: /usr/local/python373/bin/python3.7: undefined symbol: SSL_CTX_get0_param


# Find their information can not be found to solve this problem, the problem probably lies in the openssl

undefined symbol: SSL_CTX_get0_param zlib this function is a function of the source code, then recompile openssl


1 . OpenSSL installed prior to cleaning
 RM -rf / usr / local / src / openssl- 1.0 .2j # cleanup Source
 RM -rf / usr / local / Lab / openssl- 1.0 .2j # Installer Cleanup

tar zxvf openssl 1.0 2j. tar .gz
cd openssl-1.0.2j
# Compiler modify parameters, NO - zlib zlib is not required
./config --prefix=/usr/local/lab/openssl-1.0.2j no-zlib
make && make install


2 . Recompiled installation A Python 3. 7.3

# Clean up the source directory and have followed catalog
rm -rf /usr/local/src/Python-3.7.3
rm -rf /usr/local/python373

# Unpack compile and install again
tar -zxvf Python-3.7.3.tgz
cd Python-3.7.3
./configure --prefix=/usr/local/python373

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

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

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL = / usr / local / Lab / openssl- 1.0 .2j / # uncomment this line, and the original / usr / local / ssl changed our newly installed openssl directory: / usr / local / lab / openssl- 1.0 .2j /
_ssl _ssl.c \ # Uncomment this line
The -I $ -DUSE_SSL (SSL) / the include the -I $ (SSL) / the include / OpenSSL \ # Uncomment this line
 -L $ (SSL) / lib -lssl - lcrypto # Uncomment this line

# The crypt module is now disabled by default because it breaks builds
# on many systems (where -lcrypt is needed), e.g. Linux (I believe).

#_crypt _cryptmodule.c # -lcrypt    # crypt(3); needs -lcrypt on some systems


Finally, compile and install:
make && make install

# Again pip3 installation depends on not being given the
[root@srv3:/usr/local/src/Python-3.7.3]# pip3 install requests
Collecting requests
  Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
    100% |████████████████████████████████| 61kB 14.1MB/s 
Collecting certifi>=2017.4.17 (from requests)
  Downloading https://files.pythonhosted.org/packages/69/1b/b853c7a9d4f6a6d00749e94eb6f3a041e342a885b87340b79c1ef73e3a78/certifi-2019.6.16-py2.py3-none-any.whl (157kB)
    100% |████████████████████████████████| 163kB 23.3MB/s 
Collecting idna<2.9,>=2.5 (from requests)
  Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 19.8MB/s 
Collecting chardet<3.1.0,>=3.0.2 (from requests)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 23.9MB/s 
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests)
  Downloading https://files.pythonhosted.org/packages/e6/60/247f23a7121ae632d62811ba7f273d0e58972d75e58a94d329d51550a47d/urllib3-1.25.3-py2.py3-none-any.whl (150kB)
    100% |████████████████████████████████| 153kB 24.8MB/s 
Installing collected packages: certifi, idna, chardet, urllib3, requests
Successfully installed certifi-2019.6.16 chardet-3.0.4 idna-2.8 requests-2.22.0 urllib3-1.25.3

 

Guess you like

Origin www.cnblogs.com/reblue520/p/11103311.html