SSLError( Can't connect to HTTPS URL because the SSL module is not available. ) in pip command
TL;DR you're probably missing some system dependencies. sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
Read below for the full details on how we got there.
The error states that the SSL python module is not available; meaning you either don't have an appropriate ssl lib installed (probably not since you state the system python can pip install fine), or the python you built from source or otherwise installed doesn't include the ssl module.
If you built it from source, you need to be sure to set the configuration option --with-openssl
.
Also, I'd really caution against sudo pip installing anything. Use something like virtualenv to have separate python environments from the system python or other python versions you install.
EDIT:
Upon closer examination, the python configure script appears to enable ssl support by default, assuming the dev headers are present. Make sure all the dev headers are present with sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
, then retry configuring and building python.
python 3.6.10 pip3 TLS/SSL not configured
Firstly: your build of Python should allow you to use python3 -m pip
as your pip
command. The -m
flag is good practice anyway as it will make sure that you're associating the pip
you use with the correct Python interpreter. So, the python-pip python3-pip
install should not be necessary.*
Secondly: with regards to the SSL option, it's possible you might need python-openssl
. I am, ironically, getting a server-side error when I try to search for this on packages.ubuntu.com, but it's shown in this up to date example alongside libssl-dev
.
Here is a Dockerfile demonstrating both of the above points:
docker image build -f Dockerfile.60814903 -t so60814903:1 .
docker container run -it --rm so60814903:1
In that shell, you should see that you have python3 -m pip
available.
Last tip, consider a solution that will help you manage multiple Python versions alongside each other. pyenv is one such tool, and there are others out there also.
Specifically, ./configure
by default will use --with-ensurepip='upgrade'
. Here is an example of an installation that uses --with-ensurepip=no
and installs pip separately.
SSL module in Python is not available (on OSX)
The ssl
module as well as its underlying C extension appears to be a part of the python
formula:
Mac-Admin:~ admin$ python3
Python 3.7.4 (default, Sep 7 2019, 18:27:02)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl
<module 'ssl' from '/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py'>
>>> import _ssl
>>> _ssl
<module '_ssl' from '/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_ssl.cpython-37m-darwin.so'>
so it being missing most probably means package installation corruption which brew reinstall python
should fix.
Also note that while Homebrew allows multiple versions to coexist, its installation logic isn't quite designed to keep the alternative versions operational unless they are installed via a versioned formula (and e.g. routinely removes old versions in the regular brew cleanup
).
So consider using pyenv
(also available via brew
) if you need to routinely switch between Python versions -- or some 3rd-party tap that offers versioned formulae for it.
Related Topics
Docker.Errors.Dockerexception: Error While Fetching Server API Version
How to Emulate a Do-While Loop
How Does Zip(*[Iter(S)]*N) Work in Python
Keras, How to Get the Output of Each Layer
What Does "Hashable" Mean in Python
Passing a Dictionary to a Function as Keyword Parameters
How to Enable Cors on Django Rest Framework
How to Ignore the First Line of Data When Processing CSV Data
Disable Webcam's Autofocus in Linux
Clang Error: Unknown Argument: '-Mno-Fused-Madd' (Python Package Installation Failure)
Psycopg2: Insert Multiple Rows with One Query
How to Filter Foreignkey Choices in a Django Modelform