Solved – Could not find a version that satisfies the requirement in Python

Could not find a version that satisfies the requirement is a popular Python error which occurs because the support for TLS versions 1.0 and 1.1 has stopped.

In this article I am going to explain why this error happens and how to solve it using multiple possible solutions that may work for you.

Describing : Could not find a version that satisfies the requirement

This error could be confused with other errors since it is a pip error, the truth is this error is not related to any specific Python package.

The error occurs when pip install fails to install any package on Python.

To make sure the error is not related to certain package, you can run the following test

                                                                       #
pip install django
                                                                       #

If this fails, run another install

                                                                       #
pip install matplotlib
                                                                       #

If this fails, now you know that the problem is with pip.

By the way you can replace the packages with any other packages, this is just a test.

This is an example of the resulting error

                                                                       #
Could not find a version that satisfies the requirement django
No matching distribution found for django
                                                                       #

Solution 1 : install the new TLS versions

The way to solve this error is to install TLS versions newer than TLS 1.1 and TLS 1.0, since this error is happening because for PyPI support for those TLS versions has been dropped.

You can download TLS from the PyPi website or from Github

And then Unzip and install the version of your choice.

Solution 2 : use update the packages command

Another solution is to update the packages using the command bellow

                                                                       #
apt-get update && apt-get upgrade python-pip
                                                                       #

This should work for Linux, if you are on MacOs you can try the command bellow

                                                                       #
sudo easy_install -U pip
                                                                       #

If that does not work, please try running those commands as root especially on Linux

Solution 3 : run command using curl

Another solution is to run the following command using curl.

                                                                       #
curl https://bootstrap.pypa.io/get-pip.py | python
                                                                       #

After you run that command you should upgrade setuptools.

                                                                       #
pip install --upgrade setuptools
                                                                       #

Now you can try installing any Python package and the error should be gone

                                                                       #
pip install django
                                                                       #

For example installing django should work just fine.

Summing-up

The error in this article is one of the most confusing errors in Python, I hope this article has helped you solve the issue or at least pointed you in the right direction. Keep learning guys, keep coding and cheers.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/