Could not find version that satisfies requirement cv2 OpenCV

avatar
Borislav Hadzhiev

Last updated: Apr 9, 2024
5 min

banner

# Could not find version that satisfies requirement cv2 OpenCV

The error "Could not find a version that satisfies the requirement cv2 OpenCV" occurs for multiple reasons:

  • Pip installing the wrong package. The name of the package is opencv-python.
  • Installing opencv-python using a Python version that is not supported by the package.
  • Having an outdated version of pip or using pip for Python 2 instead of pip3.

could not find version that satisfies requirement cv2 opencv

shell
ERROR: Could not find a version that satisfies the requirement cv2 (from versions: none) ERROR: No matching distribution found for cv2 ERROR: Could not find a version that satisfies the requirement opencv-python ERROR: No matching distribution found for opencv-python

Try running the pip install opencv-python package as that is the name of the package that exports cv2 and other OpenCV packages.

# Install the opencv-python package

Open your terminal in your project's root directory and install the opencv-python module.

shell
# ๐Ÿ‘‡๏ธ In a virtual environment or using Python 2 pip install opencv-python # ๐Ÿ‘‡๏ธ For python 3 (could also be pip3.10 depending on your version) pip3 install opencv-python # ๐Ÿ‘‡๏ธ If you get a permissions error sudo pip3 install opencv-python # ๐Ÿ‘‡๏ธ If you don't have pip in your PATH environment variable python -m pip install opencv-python # ๐Ÿ‘‡๏ธ For python 3 (could also be pip3.10 depending on your version) python3 -m pip install opencv-python # ๐Ÿ‘‡๏ธ For Anaconda conda install -c conda-forge opencv

If you still aren't able to install the opencv-python package, try upgrading pip.

# 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.

shell
# ๐Ÿ‘‡๏ธ 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 weren't able to update pip, check out the following article with instructions on how to install and upgrade pip.

Try running the pip install opencv-python command now that pip is upgraded.

shell
pip install opencv-python pip3 install opencv-python python -m pip install opencv-python python3 -m pip install opencv-python

# Having a Python version that is not supported by opencv-python

Another common cause of the error is having a Python version that is not supported by opencv-python.

The opencv-python package supports Python versions 3.6+.

You can open the pypi page of opencv-python and view the supported Python versions in the sidebar on the left, under Meta > Requires.

opencv-python supported python versions

You can check your Python version with the python --version command.

shell
python --version python3 --version

get python 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:

  • Install launcher for all users (recommended)
  • Add Python to PATH (this adds Python to your PATH environment variable)

If that didn't help, try installing the package in a virtual environment scoped to Python 3.

# Try installing the package in a virtual environment

Another thing that might help is to create a virtual environment if you don't already have one.

shell
# ๐Ÿ‘‡๏ธ 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 opencv-python in your virtual environment pip install opencv-python

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.

You can also try running the pip install command with the --upgrade option.

shell
pip install opencv-python --upgrade pip3 install opencv-python --upgrade python3 -m pip install opencv-python --upgrade

If that didn't help, try to scope the command to the specific user.

# Install the package with the --user option

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.

shell
pip install opencv-python --user pip3 install opencv-python --user python3 -m pip install opencv-python --user

The --user option installs the package in the user's home directory.

The command basically installs the package scoped to the specific user, not for the entire system. This helps with permission issues.

If you get a permissions error, try running the command with the --user flag or with sudo.

shell
sudo pip install opencv-python sudo pip3 install opencv-python sudo python3 -m pip install opencv-python

If that didn't help, try running the command in verbose mode.

# Try running pip install opencv-python in verbose mode

If none of the suggestions helped, try running the pip install command in verbose mode.

shell
pip install opencv-python -vvv pip3 install opencv-python -vvv python -m pip install opencv-python -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.

If the error persists, follow the instructions in my Could not find a version that satisfies the requirement X article.

# Conclusion

To solve the error "Could not find a version that satisfies the requirement cv2 OpenCV", make sure:

  • To install the correct package by running pip install opencv-python.
  • You don't have an outdated version of pip.
  • You are using a Python version that is in the range of the supported by opencv-python versions.
I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev