HOWTO · Python

How to Install OpenCV in Python Conda

Install OpenCV for Python in a Conda environment with pip, conda, or Anaconda Navigator, then check that the environment can import cv2.

On this page

To install OpenCV for Python in a Conda environment, use pip, conda, or Anaconda Navigator. The pip package is named opencv-python, while Python imports it as cv2. Whichever route you choose, install into the environment where you plan to run your code, then verify the import there.

Install OpenCV with pip in a Conda environment

Activate the Conda environment you want to use before installing, so pip and Python refer to the same environment. From a terminal with that environment active, run python -m pip install opencv-python. Using python -m pip selects pip through that environment’s Python interpreter. The package is provided by the opencv-python project on PyPI.

If you do not want to activate the environment, run that environment’s Python executable with -m pip instead. Avoid using an unrelated system pip, which may install the package for a different interpreter.

Install OpenCV with conda

With the target environment active, install the Conda package by running conda install opencv. Conda resolves the package and its dependencies for that environment. Package availability can vary by platform and channel. If the package is unavailable from the default channel, try the community-maintained conda-forge channel with conda install -c conda-forge opencv (package page). This is an alternative source, not a guarantee that it contains a newer version.

Install OpenCV with Anaconda Navigator

In Anaconda Navigator, select the environment where your Python project will run. Open the package view, choose All if the package list is filtered, and search for opencv. Select the package and choose Apply to review and install the changes. Navigator installs into the selected environment; selecting a different environment changes which Python interpreter can import cv2.

Verify the cv2 installation

Run this check with the Python interpreter from the target Conda environment. It reports the imported module’s version when available and gives a clear message when this interpreter does not have the package.

import importlib.util

if importlib.util.find_spec("cv2") is None:
    print("cv2 is not installed in this Python environment.")
else:
    import cv2
    print(cv2.__version__)
cv2 is not installed in this Python environment.

The supplied run executed this check and printed cv2 is not installed in this Python environment. In an environment where OpenCV is installed, the version line displays the installed OpenCV version. If the missing-package message appears, check that you selected or activated the same environment used for installation. A successful import confirms basic availability; it does not test every OpenCV feature or configure a computer-vision project.

Choose an installation method

Use pip when you want the Python package installed through the target environment’s interpreter. Use conda when you want Conda to manage the package and its dependencies, with conda-forge as an alternative channel if needed. Choose Anaconda Navigator if you prefer a graphical package workflow. The appropriate route depends on your environment and how you manage its packages.