Last updated: Apr 9, 2024
Reading timeยท18 min
The error "Could not find a version that satisfies the requirement" occurs for multiple reasons:
pip install -r requirements.txt
command without the -r
option.pip
or using pip
for Python 2 instead of
pip3
.ERROR: Could not find a version that satisfies the requirement <package-name> (from versions: ) ERROR: No matching distribution found for <package-name>
-r
option when installing from requirements.txt
If you got the error when running the pip install requirements.txt
command,
make sure to specify the -r
option.
# ๐๏ธ In a virtual environment or using Python 2 pip install -r requirements.txt # ๐๏ธ If you use Python 3 outside a virtual environment pip3 install -r requirements.txt # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install -r requirements.txt # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) python3 -m pip install -r requirements.txt
The -r
option recursively installs the packages in your
requirements.txt file.
-r
option, the command tries to install a package named requirements.txt
which doesn't exist.If that didn't solve the error, upgrade your version of pip
.
The error is often caused when you try to install a package using an older
version of pip
than is required.
To solve the error, upgrade your version of pip
.
Here are the commands for upgrading pip
on all operating systems.
Which command works depends on your operating system and your version of Python.
# ๐๏ธ If you have pip already installed pip install --upgrade pip # ๐๏ธ If your pip is aliased as pip3 (Python 3) pip3 install --upgrade pip # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install --upgrade pip # ๐๏ธ If you don't have pip in your PATH environment variable python3 -m pip install --upgrade pip # ๐๏ธ If you have easy_install easy_install --upgrade pip # ๐๏ธ If you get a permissions error sudo easy_install --upgrade pip # ๐๏ธ If you get a permissions error when upgrading pip pip install --upgrade pip --user # ๐๏ธ Upgrade pip scoped to the current user (if you get a permissions error) python -m pip install --user --upgrade pip python3 -m pip install --user --upgrade pip # ๐๏ธ Installing directly from get-pip.py (MacOS and Linux) curl https://bootstrap.pypa.io/get-pip.py | python # ๐๏ธ If you get permissions issues curl https://bootstrap.pypa.io/get-pip.py | sudo python # ๐๏ธ 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
If you get the error "ModuleNotFoundError: No module named 'pip' in Python", check out my other article:
If the commands from the code sample didn't work for you, click on the "Install pip in Python" link.
After you upgrade pip, upgrade setuptools as well.
pip install --upgrade setuptools pip3 install --upgrade setuptools python3 -m pip install --upgrade setuptools
You can run the pip --version
command to check your pip
version.
pip --version pip3 --version python --version
You can also upgrade your Python version by downloading the installer from the official python.org website and running it.
Make sure to tick the following options if you get prompted:
Try running the pip
install command as python -m pip install example
.
This is necessary if you don't have pip
in your PATH environment variable.
# ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install <package-name> # ๐๏ธ For Python 3 outside of a virtual environment python3 -m pip install <package-name> # ๐๏ธ On Windows py -m pip install <package-name>
Make sure to replace the <package-name>
placeholder with the name of your
actual package, e.g. python -m pip install requests
.
You can also try to install the package with pip3
instead of pip
.
pip3 install <package-name>
pip
scoped to Python 2).If that didn't solve the error, try installing the package scoped to the user.
The error is often caused due to not having the necessary permissions to install a package for all users on the machine.
To solve the error, install the package scoped to the specific user with the
--user
option.
pip install <package-name> --user pip3 install <package-name> --user python3 -m pip install <package-name> --user
Make sure to replace the <package-name>
placeholder with the actual name of
the package, e.g. pip install requests --user
.
The --user
option installs the package in the user's home directory.
If you get a permissions error, try running the command with the --user
flag
or with sudo
.
sudo pip install <package-name> sudo pip3 install <package-name> sudo python3 -m pip install <package-name>
If that didn't solve the error, try upgrading the module.
The error is also caused if you try to install an older version of the package that doesn't support your version of Python.
If that is the case, try upgrading the version of the package.
pip install <package-name> --upgrade pip3 install <package-name> --upgrade python3 -m pip install <package-name> --upgrade
You can also try to install a specific version of the package.
Here is an example of how you would do this for requests
.
python3 -m pip install --pre --upgrade requests==XX.XX.XX
requests
with the name of the package you are trying to install.You also have to specify a version number after the equal signs.
You can view all of the versions of a package by entering the
pip install example==
command, where you replace example
with the actual
name of the package.
pip install example== pip3 install example==
Here is a screenshot of issuing the command in my terminal.
The output contains a tuple of all of the versions of the package from the oldest to the most recent.
You can also view all of the versions of a package by:
For example, if I wanted to install version 2.28.1
of the requests
package,
I would run the following command.
python3 -m pip install --pre --upgrade requests==2.28.1
Google for the name of the package and check if your Python version is supported by the package.
For example, if I google "requests pypi" and click on the
pypi.org page, I can see the supported
Python versions in the sidebar on the left, under Meta
> Requires
.
The screenshot shows that the package supports Python 3.7+.
To solve the error, you have to upgrade your Python version to a version that is
in the specified range and then run the pip install <package_name>
command.
You can upgrade your Python version by downloading the installer from the official python.org website and running it.
Make sure to tick the following options if you get prompted:
You can download a specific Python version that is supported by the package if the package doesn't support the latest Python version.
Different versions are available in the "Looking for a specific release" table.
The error is commonly caused when we try to pip install
a built-in Python
module.
Built-in modules are already available in the environment and should be directly
imported without running pip install
.
math
, sys
, os
and time
are built-in modules and should not be pip
installed.If you try to install the os
module, you'd get the following error.
ERROR: Could not find a version that satisfies the requirement os (from versions: none) ERROR: No matching distribution found for os
You can directly import these modules and use them without installing them.
# ๐๏ธ Directly import a built-in module import math print(math.sqrt(25)) # ๐๏ธ 5.0
Here is a list of all of the built-in modules.
You can search for the name of the module you are trying to install by pressing
CTRL+f
and typing the module's name.
Common built-in modules include: json
, urllib
, tkinter
, smtplib
,
sqlite3
, pickle
, time
, xmlrpclib
and csv
.
Try running your code with python your_file.py
as the module you are trying to
install might already be available in the environment.
The error is often caused when we:
Make sure you are spelling the module's name correctly by googling one of the following:
import requests
If you are installing from a requirements.txt
file with
pip install -r requirements.txt
, you have to make sure the file contains all
of the packages and their dependencies.
This can be done by running pip install <package-name>
and generating a new
requirements.txt
file that contains all of the dependencies.
pip freeze > requirements.txt pip3 freeze > requirements.txt
The error commonly occurs if your requirements.txt
file contains only some of
the dependencies of the packages.
You can also add the dependencies of the packages manually to your
requirements.txt
file based on the output from the error message.
Some packages cannot be pip
installed because they are not available on
pypi
.
If that is the case with your specific package, you can install it manually.
Here is an example of how you would install the requests package manually.
Code
and then
click Download ZIP
.setup.py
file. It should be in the root directory.python setup.py install
command.sudo python setup.py install
command.python setup.py install --user
.You can often find download files for a specific module on the pypi
page of
the package by clicking on "Download files".
--pre
optionThe --pre
option makes it so pip
includes pre-release and development
versions of the package. By default pip
only finds stable versions.
pip install requests --pre pip3 install requests --pre python -m pip install requests --pre python3 -m pip install requests --pre py -m pip install requests --pre
Make sure to replace requests
with the name of the actual package you are
trying to install.
--pre
if you need to get access to a feature that is not yet available in the stable version.Another thing that might help is to create a virtual environment if you don't already have one.
# ๐๏ธ Use the correct version of Python when creating VENV python3 -m venv venv # ๐๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐๏ธ Upgrade pip pip install --upgrade pip # ๐๏ธ Install <package-name> in your virtual environment pip install <package-name>
If the python3 -m venv venv
command doesn't work, try the following 2
commands:
python -m venv venv
py -m venv venv
Make sure to use the correct activation command depending on your operating system.
Your virtual environment will use the version of Python that was used to create it.
If none of the suggestions helped, try running the pip install
command in
verbose mode.
pip install <package-name> -vvv pip3 install <package-name> -vvv python -m pip install <package-name> -vvv
The -v
option stands for verbose mode and can be used up to 3 times.
When the pip install
command is run in verbose mode, the command shows more
output and how the error occurred.
To solve the error "Could not find a version that satisfies the requirement", make sure:
requirements.txt
file with the -r
option, e.g.
pip install -r requirements.txt
.pip
.pip install
.Here are some examples of solving the error for specific Python packages.
The error "Could not find a version that satisfies the requirement pandas" occurs for multiple reasons:
pandas
using a Python version that is not supported by the
package.pip
or using pip
for Python 2 instead of
pip3
.ERROR: Could not find a version that satisfies the requirement pandas (from versions: none) ERROR: No matching distribution found for pandas
The pandas
package supports Python versions 3.8+.
You can open the pypi page of pandas and
view the supported Python versions in the sidebar on the left, under Meta
>
Requires
.
You can check your Python version with the python --version
command.
python --version python3 --version
If you have an older Python version than 3.8, download the latest version from the official python.org website and run the installer.
Make sure to tick the following options if you get prompted:
Once you have a Python version in the supported range, try installing pandas.
# ๐๏ธ In a virtual environment or using Python 2 pip install pandas # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) pip3 install pandas # ๐๏ธ If you get a permissions error sudo pip3 install pandas # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install pandas # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) python3 -m pip install pandas # ๐๏ธ For Anaconda conda install -c anaconda pandas
After you install the pandas package, try importing it as follows.
import pandas as pd print(pd.__version__)
If the error is not resolved, try upgrading your version of pip
.
# ๐๏ธ If you have pip already installed pip install --upgrade pip # ๐๏ธ If your pip is aliased as pip3 (Python 3) pip3 install --upgrade pip
The error "Could not find a version that satisfies the requirement numpy" occurs for multiple reasons:
numpy
using a Python version that is not supported by the
package.pip
or using pip
for Python 2 instead of
pip3
.ERROR: Could not find a version that satisfies the requirement numpy (from versions: ) ERROR: No matching distribution found for numpy
The numpy
package supports Python versions 3.8+.
You can open the pypi page of numpy and view
the supported Python versions in the sidebar on the left, under Meta
>
Requires
.
You can check your Python version with the python --version
command.
python --version python3 --version
If you have an older Python version than 3.8, download the latest version from the official python.org website and run the installer.
Make sure to tick the following options if you get prompted:
Once you have a Python version in the supported range, try installing numpy.
# ๐๏ธ In a virtual environment or using Python 2 pip install numpy # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) pip3 install numpy # ๐๏ธ If you get a permissions error sudo pip3 install numpy # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install numpy # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) python3 -m pip install numpy # ๐๏ธ For Anaconda conda install -c anaconda numpy
After you install the numpy package, try importing it as follows.
import numpy as np a = np.arange(6) a2 = a[np.newaxis, :] print(a2.shape)
If the error is not resolved, try upgrading your version of pip
.
# ๐๏ธ If you have pip already installed pip install --upgrade pip # ๐๏ธ If your pip is aliased as pip3 (Python 3) pip3 install --upgrade pip
The error "Could not find a version that satisfies the requirement yaml" occurs for multiple reasons:
pyyaml
.pyyaml
using a Python version that is not supported by the
package.pip
or using pip
for Python 2 instead of
pip3
.ERROR: Could not find a version that satisfies the requirement yaml (from versions: none) ERROR: No matching distribution found for yaml
Open your terminal in your project's root directory and install the pyyaml module.
# ๐๏ธ In a virtual environment or using Python 2 pip install pyyaml # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) pip3 install pyyaml # ๐๏ธ For Anaconda conda install -c conda-forge pyyaml
After you install the pyyaml package, try importing it as follows.
import yaml print(yaml.load(""" - bobby - hadz - . - com """, Loader=yaml.Loader) )
If you still aren't able to install the
pyyaml package, try upgrading pip
.
# ๐๏ธ If you have pip already installed pip install --upgrade pip # ๐๏ธ If your pip is aliased as pip3 (Python 3) pip3 install --upgrade pip
Another common cause of the error is having a Python version that is not
supported by pyyaml
.
The pyyaml
package supports Python versions 3.6+.
You can open the pypi page of pyyaml and
view the supported Python versions in the sidebar on the left, under Meta
>
Requires
.
You can check your Python version with the python --version
command.
python --version python3 --version
If you have an older Python version than 3.6, download the latest version from the official python.org website and run the installer.
Make sure to tick the following options if you get prompted:
If that didn't help, try installing the package in a virtual environment scoped to Python 3.
The error "Could not find a version that satisfies the requirement tkinter"
occurs when we try to install tkinter
using pip.
To solve the error, use an operating system-specific command to install
tkinter
or use Python 3 where tkinter is available as a built-in module.
ERROR: Could not find a version that satisfies the requirement tkinter (from versions: none) ERROR: No matching distribution found for tkinter
pip
but it can be installed using operating system-specific commands.Open your terminal and run the following command to install tkinter.
# ๐๏ธ === UBUNTU / DEBIAN === sudo apt-get install python3-tk # ๐จ Make sure to specify the correct Python version. # For example, my Python version is 3.10, so I would install as sudo apt-get install python3.10-tk # ๐๏ธ === MacOS === brew install python-tk@3.10 # ๐จ Make sure to specify the correct Python version. # For example, if you run Python v3.9 run adjust command to brew install python-tk@3.9 # ๐๏ธ === Fedora === sudo dnf install python3-tkinter # ๐๏ธ === CentOS === sudo yum install python3-tkinter
Windows
, you have to make sure to tick the checkboxtcl/tk and IDLE
when installing Python.If you already installed Python:
Modify
.tcl/tk and IDLE
checkbox to install tkinter
for your
Python version.Make sure to tick the following options if you get prompted:
Tkinter comes as a built-in module in Python 3 and is made available without requiring installation.
Now you should be able to import and use the tkinter module.
import tkinter as tk from tkinter import ttk root = tk.Tk() frm = ttk.Frame(root, padding=10) frm.grid() ttk.Label(frm, text="Hello World!").grid(column=0, row=0) ttk.Button(frm, text="Quit", command=root.destroy).grid(column=1, row=0) root.mainloop()
When you run your code with python file_name.py
, you might be running the
script with Python 2.
Use the python --version
command if you need to check your Python version.
python --version
You can try to run the script with python3 file_name.py
to have the command
scoped to Python 3.
python3 example_file.py
The error "Could not find a version that satisfies the requirement virtualenv" occurs for multiple reasons:
virtualenv
using a Python version that is not supported by the
package.pip
or using pip
for Python 2 instead of
pip3
.Make sure your Python version is one of the supported by virtualenv
versions.
The virtualenv package supports Python versions 3.6+.
You can open the pypi page of virtualenv
and view the supported Python versions in the sidebar on the left, under
Meta
> Requires
.
You can check your Python version with the python --version
command.
python --version python3 --version
If you have an older Python version than 3.6, download the latest version from the official python.org website and run the installer.
Make sure to tick the following options if you get prompted:
Update your version of pip
before installing virtualenv
.
# ๐๏ธ If you have pip already installed pip install --upgrade pip # ๐๏ธ If your pip is aliased as pip3 (Python 3) pip3 install --upgrade pip
Run the following command to install virtualenv
.
pip install virtualenv # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) pip3 install virtualenv # ๐๏ธ If you get a permissions error sudo pip3 install virtualenv # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install virtualenv # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) python3 -m pip install virtualenv # ๐๏ธ For Anaconda conda install -c anaconda virtualenv
The error "Could not find a version that satisfies the requirement django" occurs for multiple reasons:
Django
using a Python version that is not supported by the
package.pip
or using pip
for Python 2 instead of
pip3
.ERROR: Could not find a version that satisfies the requirement django (from versions: ) ERROR: No matching distribution found for django
If that didn't help, make sure your Python version is one of the supported by
Django
versions.
The Django
package supports Python versions 3.8+.
You can open the pypi page of Django and
view the supported Python versions in the sidebar on the left, under Meta
>
Requires
.
You can check your Python version with the python --version
command.
python --version python3 --version
If you have an older Python version than 3.8, download the latest version from the official python.org website and run the installer.
Make sure to tick the following options if you get prompted:
Update your version of pip
before installing virtualenv
.
# ๐๏ธ If you have pip already installed pip install --upgrade pip # ๐๏ธ If your pip is aliased as pip3 (Python 3) pip3 install --upgrade pip
Run the following command to install Django.
# ๐๏ธ In a virtual environment or using Python 2 pip install Django # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) pip3 install Django # ๐๏ธ If you get a permissions error sudo pip3 install Django # ๐๏ธ If you don't have pip in your PATH environment variable python -m pip install Django # ๐๏ธ For python 3 (could also be pip3.10 depending on your version) python3 -m pip install Django # ๐๏ธ For Anaconda conda install -c anaconda django
You can learn more about the related topics by checking out the following tutorials: