the ssl module in Python is not available

Damn You OpenSSL

This is just a quick note/rant/reminder-to-self about an issue I ran into updating this site. I got the following errors when using the (admittedly outdated) AWS command line tools to deploy:

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

The other error I was seeing was this:

from urllib3.util.ssl_ import (ImportError: cannot import name ssl)

It took me a good 1.5 hours of googling and trying a series of commands in to deploy a website update today? Why? Because I use AWS to host this website. AWS uses a command line tool which uses the python programming language which relies on openssl which encrypts requests to websites and other servers. I previously had to reinstall openssl to fix other programming languages like Ruby and Elixir because it was already broken. I had done this about 3 months ago but never fixed python. So the solution was to reinstall python, update pip (the tool that manages python libraries). All this was complicated by the fact that I also use a tool called asdf which manages all these programming languages and different versions of them. So the final step to getting the AWS tool to work was the command

asdf reshim python

which I used to know but had since forgotten, to tell my computer where the command line tools like aws live on my machine.

So 1.5 hours to figure out I needed to type in:

asdf uninstall python
asdf install python
python install pip
pip install awscli
asdf reshim python

Once all this was figured out and done, then I could deploy my site. I looked around for solutions that did not require reinstalling python, but never got any of them to work. Since I had already gone through this with Ruby and Elixir I figure this is the most straightforward way.

So to summarize:

  • For some reason, I had to update/reinstall openssl
  • This breaks the SSL/TLS libraries in Elixir, Ruby and Python, probably other languages as well
  • I had to resinstall python so it would take advantage of openssl
  • I had to update pip
  • I had to reshim python in asdf, since asdf controls the programming language and its command line tools.

Incidentally, the newer versions of the aws tools have their own separate copy of python bundled with them, so you typically don’t have to worry about reinstalling python and updating pip for this.