Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 3.7 Can't connect to HTTPS URL because the SSLmodule is not available

Tags:

python

ssl

I am in the process of installing Python 3.7 on my dedicated server running centos 6.10 After jumping through some hoops to try and do this, I am reaching yet another error. Using Python 3.7 to try and stay up to date, it is a rather common issue to have SSL issues with pip installation. I came to the conclusion that the best way to fix this problem was to get the right version of OpenSSL. So I did so, and edited my python modules/Setup.dist file, reconfigured it, reran make altinstall, and while everything seemed fine. For some reason, the command Python3.7 which was the command I used for running this python before, suddenly became unrecognized as a command, while in the Python3.7 directory was a folder python now which when executed (after editing the environment path turned on the Python3.7. Beforehand this was not the case, and it was just Python3.7 Does anyone know what could have happened here?

Also, I am about at the end of my wits with this whole SSL thing, and I have read about every article under the sun it feels like. Here is a list of some commands I executed as of recent:

#Unpacked Python3.7 into /usr/src directory
./configure --enable-optimizations --enable-loadable-sqlite-extensions
make altinstall

#installation failed from no '_ctypes' module

yum install libffi-devel

#repeat configure above
#yaaay python
#Successfully installed pip-10.0.1 setuptools-39.0.1 was the final message of the installation

Python3.7 -m venv /my/project/directory/ENV
pip install {library}

#this is where my issues began with SSL

Logs:

(ENV) [[email protected] ProjectDirectory]# pip3 install twisted
pip is configured with locations that require TLS/SSL, however, the SSL module in Python is not available.
Collecting twisted
  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/twisted/
  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/twisted/
  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/twisted/
  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/twisted/
  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/twisted/
  Could not fetch URL https://pypi.org/simple/twisted/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/twisted/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
  Could not find a version that satisfies the requirement twisted (from versions: )
No matching distribution found for twisted
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSLmodule is not available.")) - skipping

So I was like ok cool. No worries. The most recent version of Python can't even get pip3 right out of the box. Wonderful. Well, I started searching google as we do and came to the conclusion that everybody was just reconfiguring their python again and it magically worked. Not sure why, but ok. I was into it. I found this article:

https://techglimpse.com/install-python-openssl-support-tutorial/

Thinking ok cool. If I can get python3.7 SSL, then it should get pip3 to work right? Wrong. Unfortunately, if I kick on Python3.7 in the new strange way I mentioned above, and type import ssl I get this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/src/Python-3.7.0/Lib/ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'

Could anyone provide me with some assistance? I am sort of lost in an ocean, and I don't know how to swim... Anything would be awesome, but I am a noob to this server admin stuff so the more simple it is, the better :) Thank you in advance.

EDIT: By the way

yum install openssl

and

yum install openssl-devel

both results in 'already installed' flag... So I don't think that's another solution. However when I did the install manually I used version 1.1.1 because I know that 3.7 dropped support for a few different versions of OpenSSL for whatever reason. The one that is already yum installed is 1.0.2 I think. I don't know if there is a capacity for the centos 6.10 platform though as far as version limits.

like image 655
Pixelknight1398 Avatar asked Sep 29 '18 08:09

Pixelknight1398


2 Answers

I had a similar issue on my mac OS where I couldn't install anything or even upgrade pip from within a virtual environment due to SSL issues.

What worked for me was doing the following from inside the virtual environment

  1. sudo chown -R ${whoami} /usr/local/Cellar followed by

  2. brew install openssl

What is the ${whoami} in the first command?

It's a placeholder; what you should put there when you run the command is your actual current user.

If you don't know your user, in the command line type

whoami

The output is your user. So if you type that and get johnsmith as output, when you run the first command, you'll replace "${whoami}" with "johnsmith" like this:

sudo chown -R johnsmith /usr/local/Cellar

like image 125
hlp Avatar answered Sep 20 '22 18:09

hlp


Upload libcrypto-1_1-x64.dll and libcrypto-1_1-x64.pdb file on \Anaconda3\DLLs Then your problem will be solved Those files may be available in \Anaconda3\Library\bin directory or you can download from the official website.

like image 20
Subhadip Mondal Avatar answered Sep 18 '22 18:09

Subhadip Mondal