Last updated: Apr 9, 2024
Reading timeยท5 min
The error "Could not find a version that satisfies the requirement cv2 OpenCV" occurs for multiple reasons:
opencv-python
.opencv-python
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 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.
opencv-python
packageOpen your terminal in your project's root directory and install the opencv-python module.
# ๐๏ธ 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
.
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 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.
pip install opencv-python pip3 install opencv-python python -m pip install opencv-python python3 -m pip install opencv-python
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
.
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.
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 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.
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.
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 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.
If you get a permissions error, try running the command with the --user
flag
or with sudo
.
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.
If none of the suggestions helped, try running the pip install
command in
verbose mode.
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.
To solve the error "Could not find a version that satisfies the requirement cv2 OpenCV", make sure:
pip install opencv-python
.pip
.opencv-python
versions.