How to fix 'Could not find a version that satisfies the requirement' error

When installing Python packages with pip, you might encounter the following error:

ERROR: Could not find a version that satisfies the requirement ?
ERROR: No matching distribution found for ?

This error can happen for many reasons. Here are the most common ones:

  1. Installing from requirements.txt file without adding the -r option
  2. You mistyped the package name (not found in PyPI)
  3. The package doesn’t support your operating system
  4. Your pip is outdated
  5. Your Python version is not supported

This tutorial will show you examples that cause this error and how to fix them in practice.

1. You install from requirements.txt

When you install packages from a requirements.txt file, you need to specify the -r or --requirement option so that Python knows you want to install from a requirements file.

If you run the install command without the -r option, Python thinks you’re trying to install a package named requirements.txt instead:

pip install requirements.txt
Collecting requirements.txt

ERROR: Could not find a version that satisfies the requirement requirements.txt 
(from versions: none)
ERROR: No matching distribution found for requirements.txt

See how pip responds with ‘Collecting requirements.txt’? This shows that pip is seeking a package with that name instead of looking into your requirements.txt file.

To resolve this error, add the -r option to the command:

pip install -r requirements.txt

Now pip will install the packages specified in the requirements file, and you won’t receive the error.

2. You mistyped the package name (not found in PyPI)

Another cause for this error is that you mistyped the package name. For example, suppose you want to install aalib package:

pip install aalib
ERROR: Could not find a version that satisfies the requirement aalib 
(from versions: none)
ERROR: No matching distribution found for aalib

To resolve this error, you need to visit PyPI website and find the package you’re trying to install.

In this case, the aalib package’s name is actually python-aalib so change the name accordingly:

pip install python-aalib

Type the name exactly as specified in the PyPI website, and this error should be resolved.

3. The package doesn’t support your operating system

Another possible cause for this error is you’re using an operating system that’s not supported by the package.

For example, when I attempt to install TensorFlow on my M1 Macbook, I get this error:

pip3 install tensorflow
ERROR: Could not find a version that satisfies the requirement tensorflow 
(from versions: none)
ERROR: No matching distribution found for tensorflow

This error occurs because tensorflow isn’t compatible with Apple Silicone chips.

To resolve the error, I need to install the tensorflow-macos package instead:

pip3 install tensorflow-macos

This time, the package is installed and the error doesn’t occur.

4. Your pip is outdated

Another possible cause for this error is the package requires the latest version of pip to install properly.

You can upgrade pip using one of the following commands:

python -m pip install --upgrade pip

# For python 3:
python3 -m pip install --upgrade pip

# alternative for Windows
py -m pip install --upgrade pip

# alternative for Ubuntu/Debian
sudo apt-get update && apt-get upgrade python-pip

# alternative for Red Hat / CentOS / Fedora
sudo yum install epel-release
sudo yum install python-pip
sudo yum update python-pip

Once pip is upgraded, try to run the install command again. You won’t receive the error again if an outdated pip version is the cause.

5. Your Python version is not supported

Depending on what package you’re trying to install, the Python version you have may not be supported.

For example, the tensorflow-macos package only supports Python version >= 3.8 and <3.11, so if you have Python 3.7 or 3.11, you’ll get this error.

You can find a clue about the supported Python version in the “Meta” section of the PyPI website:

Unfortunately, the information is mostly incomplete as it doesn’t show the highest Python version supported.

Still, you can at least use the info to make sure the Python version you have is supported by the package.

Sometimes, you need to upgrade the Python version to install the package.

Conclusion

The error message Could not find a version that satisfies the requirement ? occurs whenever the package you’re trying to install is missing or incompatible. There are many potential causes for this error.

The examples in this tutorial could help you figure out the cause and fix this error.

I hope this tutorial helps. See you in other tutorials! 👋

Take your skills to the next level ⚡️

I'm sending out an occasional email with the latest tutorials on programming, web development, and statistics. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.