python_finn
python_finn

Reputation: 31

How to force Python 3.9 to compile using OpenSSL 1.1.1 correctly in Centos 7

Running Centos 7 and have both Python 3.6 and 3.9 installed as altinstalls.

I've installed openssl 1.1.1 and can verify that by using "openssl version" but every time I try to install a new module with Python 3.9 I get SSL errors.

[root@server Modules]# openssl version OpenSSL 1.1.1k 25 Mar 2021

[root@server Modules]# python3 -m pip install meraki WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/meraki/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/meraki/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/meraki/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/meraki/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/meraki/ Could not fetch URL https://pypi.org/simple/meraki/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/meraki/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping ERROR: Could not find a version that satisfies the requirement meraki (from versions: none) ERROR: No matching distribution found for meraki WARNING: You are using pip version 21.1.3; however, version 23.1.2 is available. You should consider upgrading via the '/usr/local/bin/python3 -m pip install --upgrade pip' command.

I also navigated to /usr/src/Python-3.9.6/Modules and edited the Setup file to uncomment the SSL lines.

python Setup file with SSL lines uncommented

But I think that the location that the Setup file points to doesn't have any ssl files in it, so the location variable might need to change.. but I don't know how to find the actual location of my SSL install.

Here are the outputs of which ssl and which openssl

[root@server Modules]# which ssl /usr/bin/which: no ssl in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/cloud/.local/bin:/home/cloud/bin)

[root@server Modules]# which openssl /usr/bin/openssl

I have tried re-installing OpenSSL which I expected to force the OpenSSL into a location that Python 3.9 could find it. I saw no change in Python 3.9's behavior when I try calling pip install.

I also uncommented the SSL lines in the Setup file, expecting that to "turn on" the SSL capabilities of Python 3.9 - but again I saw no change in the behavior of PY3.9.

I also tried running these lines based on another stackoverflow answer I found:

export CFLAGS="$CFLAGS $(pkg-config --cflags openssl11)"
export LDFLAGS="$LDFLAGS $(pkg-config --libs openssl11)"

but got this output:

[root@server Python-3.9.6]# export CFLAGS="$CFLAGS $(pkg-config --cflags openssl11)" Package openssl11 was not found in the pkg-config search path. Perhaps you should add the directory containing openssl11.pc' to the PKG_CONFIG_PATH environment variable
No package 'openssl11' found`

The output instructed me to "add the directory containing `openssl11.pc' to the PKG_CONFIG_PATH" but I don't know how to find the location of 'openssl11.pc' or how I would add it to the env. variable.

Upvotes: 3

Views: 3520

Answers (1)

Fco RV
Fco RV

Reputation: 11

It happened to me and I solved it by installing openssl-devel or openssl-dev package from the package installer (yum in your case I guess).

Upvotes: 0

Related Questions