If you use Anaconda or Miniconda, install OpenCV via conda-forge rather than pip to avoid dependency conflicts between conda and pip packages.
Install
Install OpenCV with conda on Windows
# Install into base environment (not recommended):
(base)> conda install -c conda-forge opencv
# Better: create a dedicated environment:
(base)> conda create -n cv_env python=3.11 opencv -c conda-forge
(base)> conda activate cv_env
(cv_env)>
# Verify:
(cv_env)> python -c "import cv2; print(cv2.__version__)"
4.10.0
The conda-forge OpenCV version may lag slightly behind pip. As of mid-2026, conda-forge typically has OpenCV 4.10.x while pip has 4.12.x.
With contrib modules
Install OpenCV contrib via conda
# Install with contrib modules:
(cv_env)> conda install -c conda-forge opencv libopencv py-opencv
# Or create new env with everything:
(base)> conda create -n cv_full python=3.11 -c conda-forge
(base)> conda activate cv_full
(cv_full)> conda install -c conda-forge opencv libopencv py-opencv
Mixing pip and conda
When to use pip inside conda
If you need a newer OpenCV version than conda-forge provides, you can use pip inside a conda environment. However, always install conda packages first:
# Create conda env with Python and numpy from conda:
(base)> conda create -n cv_pip python=3.11 numpy -c conda-forge
(base)> conda activate cv_pip
# Then install OpenCV from pip:
(cv_pip)> pip install opencv-python
This approach works well. The key rule: install numpy and other heavy scientific packages from conda first, then add pip packages on top.
Jupyter integration
Use OpenCV in Jupyter Notebook
(cv_env)> conda install -c conda-forge jupyter ipykernel
(cv_env)> python -m ipykernel install --user --name cv_env --display-name "Python (cv_env)"
(cv_env)> jupyter notebook
# In notebook: Kernel > Change kernel > Python (cv_env)
import cv2
from IPython.display import Image
# cv2.imshow() does not work in Jupyter — use this instead:
cv2.imwrite("/tmp/test.jpg", img)
Image("/tmp/test.jpg")
FAQ
Conda questions
conda install opencv says "PackageNotFoundError"
Add the conda-forge channel:
conda install -c conda-forge opencv. If it still fails, update conda first: conda update -n base -c defaults conda.OpenCV from conda vs pip — which is better?
For Anaconda users: conda-forge is generally more stable because it resolves all native library dependencies (like libpng, libjpeg) consistently. pip wheels bundle these, which can occasionally conflict. For the latest version, pip is faster to update.
cv2.imshow crashes in conda/Jupyter
Jupyter Notebook does not support cv2.imshow() natively. Use
cv2.imwrite() to save the image, then display with IPython.display.Image(). Or use matplotlib: plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)).