SSL module in Python is not available (on OSX)


I’m having trouble running pip install in a virtualenv on OSX 10.13. I already have run brew install openssl and the path /usr/local/include/openssl points to ../opt/openssl/include/openssl. Does anyone know how to fix this? This started happening after I reinstalled python using brew install.

pip is configured with locations that require TLS/SSL, however the ssl
module in Python is not available. Collecting Pillow Could not fetch
URL There was a problem
confirming the ssl certificate: Can’t connect to HTTPS URL because the
SSL module is not available. – skipping Could not find a version
that satisfies the requirement Pillow (from versions: ) No matching
distribution found for Pillow

UPDATE: Here’s some more info:

✗ which python
✗ which pip
✗ python --version
Python 3.7.4
✗ pip --version
pip 19.1.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
✗ brew info python
python: stable 3.7.4 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
/usr/local/Cellar/python/3.6.5_1 (4,795 files, 100.0MB)
  Poured from bottle on 2019-10-08 at 14:39:37
/usr/local/Cellar/python/3.7.4_1 (3,903 files, 60.6MB) *
  Poured from bottle on 2019-10-08 at 14:37:10

Yes, I have both 3.6.5_1 and 3.7.4_1 installed as I may need to switch between the two at times.

✗ brew unlink openssl
Unlinking /usr/local/Cellar/openssl/1.0.2s... 0 symlinks removed
Asked By: John M.



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/'>
>>> 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/'>

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.

Answered By: ivan_pozdeev

Mac OSX Catalina (and same issue on OSX Mojave) Pyenv

For anyone searching this topic, I had the same presenting problem, but had Python installed via both Homebrew and Pyenv!! It would have been better (IMO) to just use Pyenv to easily manage versions. As mentioned by @ivan_pozdeev in their answer, but here’s some detail you might want.

If your situation is similar, none of the above solutions would be quite enough to set things right. Partially I was helped by a Pyenv related answer here: I also happened to have pyenv-virtualenv installed, so mentioning that as well, as it’s common to use these two together.

I finally took the following steps to resolve the issue:

brew uninstall python
rm -rf $(pyenv root)
brew uninstall pyenv-virtualenv   # you may not have this installed, but...
brew uninstall pyenv

Now, for a clean installation manageable with Pyenv:

brew install pyenv
pyenv install 3.6.10  (or whatever version you want)

This gave me a clean, working install of Python 3.6.10, and if I wanted or needed to, I could install a different version and switch between with Pyenv.

Answered By: Matt Morgan

I had the same error and it was because I was using python 3.6.5 in my pyenv environment.
The below treatment worked for me.

pyenv install 3.7.3
pyenv global 3.7.3
Answered By: Yasunari Nishi

I had a similar problem with Catalina and could not get homebrew reinstall to work. I tried several thing.

brew reinstall openssl
brew reinstall pyenv
brew reinstall pyenv-virtualenv

Ultimately the only thing that worked for me was to completely uninstall both as well as the underlying python installations and then reinstall everything.

brew uninstall pyenv pyenv-virtualenv
brew install pyenv pyenv-virtualenv
pyenv uninstall 3.x.x
pyenv install 3.x.x
pip install -r requirements.txt
Answered By: charlton_austin

I also had this error and I fixed it with brew update && brew upgrade

Answered By: baskcat

My fix is to reinstall pyenv and python

 brew uninstall pyenv pyenv-virtualenv
 brew install pyenv pyenv-virtualenv
 pyenv uninstall 3.6.5
 pyenv install 3.6.5
Answered By: tzatalin

This problem might also be, because your python distribution was compiled using the wrong version of openssl.

Support for OpenSSL 1.1.x, was only added in Python 2.7.13, 3.5.3 and
3.6.0 (see

So if you are trying to install an older version of Python you must first uninstall the new version of openssl with brew and only then you can install an older version of Python with pyenv

brew uninstall --ignore-dependencies [email protected]
pyenv uninstall 3.5.2  # deinstall old versions compiled with the wrong version of openssl
pyenv install 3.5.2

On the other side, if you are trying to install newer version of Python make sure you have installed the latest version of openssl available, before you install them with pyenv:

brew upgrade openssl
pyenv uninstall 3.7.4 # deinstall old versions compiled with the wrong version of openssl
pyenv install 3.7.4
Answered By: asmaier

I had the same error. I tried re-installing OpenSSL. That didn’t help. I finally went to and downloaded the latest official/stable installer and ran it. That fixed my issues.

That was probably overkill but it resolved the issue.

Answered By: Marcus Talcott

I was also having this problem on macOS Monterey and Anaconda. The SSL module could be found in the base environment, but in another environment, it would not be found.

I was able to fix this by doing the following:

conda activate my_env
conda update --all

After this, I started getting a new error that libzmq was not found, so I installed Zeromq, as stated in

conda install -c anaconda zeromq

Restarted the terminal, and now everything works in the environment!

Answered By: Clifford Kintanar
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.