Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "ssl module in Python is not available" in CentOs

Tags:

python

centos

New Python 3.7.1 installation on GoDaddy VPS CentOs 7. Attempt pip3 install virtualenv or python 3 -m pip install virtualenv and get:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

openssl-devel installed and up to date

This question has been asked and answered many times, but the solutions I've found have not solved my problem. Thank you all!

I tried the CentOs and Linux-based solutions in the following:

"SSL module in Python is not available" when installing package with pip3 # To allow for building python ssl libs yum install openssl-devel # Download the source of any python version cd /usr/src wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz tar xf Python-3.7.1.tar.xz cd Python-3.7.1

  # Configure the build w/ your installed libraries
  ./configure

  # Install into /usr/local/bin/python3.6, don't overwrite global python bin
  make altinstall

Trying to install packages with Python 3.7.2 pip causes TSL/SSL errors

"SSL module in Python is not available" when installing package with pip3

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

pip cannot confirm SSL certificate: SSL module is not available

"ssl module in Python is not available" and pip cannot confirm SSL certificate: SSL module is not available

  `uncommented suggestions for CentOs
  make install failed:
    gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration   -I. -I./Include     -DUSE_SSL -I/include -I/include/openssl -c ./Modules/_ssl.c -o Modules/_ssl.o
    ./Modules/_ssl.c:74:6: error: #error "libssl is too old and does not support X509_VERIFY_PARAM_set1_host()"
    ./Modules/_ssl.c: In function ‘_ssl_configure_hostname’:
    ./Modules/_ssl.c:861: error: implicit declaration of function ‘SSL_get0_param’
    ./Modules/_ssl.c:861: warning: initialization makes pointer from integer without a cast
    ./Modules/_ssl.c:863: error: implicit declaration of function ‘X509_VERIFY_PARAM_set1_host’
    ./Modules/_ssl.c:869: error: implicit declaration of function ‘X509_VERIFY_PARAM_set1_ip’
    ./Modules/_ssl.c: In function ‘_ssl__SSLContext_impl’:
    ./Modules/_ssl.c:2988: error: ‘X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS’ undeclared (first use in this function)
    ./Modules/_ssl.c:2988: error: (Each undeclared identifier is reported only once
    ./Modules/_ssl.c:2988: error: for each function it appears in.)
    ./Modules/_ssl.c:3093: error: implicit declaration of function ‘SSL_CTX_get0_param’
    ./Modules/_ssl.c:3093: warning: assignment makes pointer from integer without a cast
    ./Modules/_ssl.c:3099: error: implicit declaration of function ‘X509_VERIFY_PARAM_set_hostflags’
    ./Modules/_ssl.c: In function ‘get_verify_flags’:
    ./Modules/_ssl.c:3397: warning: assignment makes pointer from integer without a cast
    ./Modules/_ssl.c: In function ‘set_verify_flags’:
    ./Modules/_ssl.c:3410: warning: assignment makes pointer from integer without a cast
    ./Modules/_ssl.c: In function ‘set_host_flags’:
    ./Modules/_ssl.c:3573: warning: assignment makes pointer from integer without a cast
    make: *** [Modules/_ssl.o] Error 1`

https://www.tomordonez.com/pip-install-ssl-module-python-is-not-available.html

like image 898
Eric Avatar asked Jun 11 '19 22:06

Eric


3 Answers

Here is a working solution for Python 3.7.9 and CentOS 7.8.2003:

su - root
yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel -y
cd /usr/src
wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
tar xzf Python-3.7.9.tgz
cd Python-3.7.9

In /usr/src/Python-3.7.9/Modules/Setup.dist, uncomment these 4 lines:

SSL=/usr/local/ssl
_ssl _ssl.c \
    -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    -L$(SSL)/lib -lssl -lcrypto

And finally:

./configure --enable-optimizations
make altinstall
like image 118
Kevin Lemaire Avatar answered Oct 15 '22 22:10

Kevin Lemaire


I have seen this error when the version of openssl is incompatible. This is more likely when you're installing a newer Python (such as 3.7.2) on a not-as-recent version of the Linux system.

I would check to see what version of SSL libraries are expected with this version of Python and if necessary, install them locally.

This is a basic description of building the SSL libraries: DreamHost instructions for Installing Local OpenSSL Version

You will want to build Python again with the following option added to your invocation of ./config:

--with-openssl=/path/to/your/local/install
like image 9
rholmes Avatar answered Oct 15 '22 22:10

rholmes


Please read this article

Basically you need to install openssl first and uncomment ssl related lines in Modules/Setup file in python source code before to make install. This worked to me on installing Python 3.8.

like image 3
Ricardo Carmo Avatar answered Oct 15 '22 21:10

Ricardo Carmo