![]() |
OpenCV 4.13.0-dev
Open Source Computer Vision
|
This quick-start shows the recommended way for most users to get OpenCV in Python: install from PyPI with pip. It also explains virtual environments, platform notes, and common troubleshooting. If you need OS‑specific alternatives (system packages or source builds), see the OS pages linked below, but those are not required for typical Python use.
Using a virtual environment keeps project dependencies isolated. Tools that create or activate envs include:
venv (built-in) and virtualenvIf imports fail inside an IDE, verify the interpreter selected by the IDE matches the environment where you installed OpenCV.
python3. Use python3 -m venv .venv and python3 -m pip .... If you cannot use a virtual env, pip --user installs to your home directory: python3 -m pip install --user opencv-python.winget install Python.Python.3. Make sure “Add python to PATH” is enabled or use the “Open in terminal” from your IDE, which selects the right interpreter automatically.python3 or a managed one (Homebrew or Python.org). Always prefer a virtual environment.opencv-python: core OpenCV modules with GUI/backendsopencv-contrib-python: includes contrib modules in addition to the coreopencv-python-headless: no GUI/backends (ideal for servers/containers/CI)opencv-contrib-python-headless: contrib + headlessInstall exactly one of these per environment.
Please start with opencv-python project README
Pip is trying to build from source Symptoms: very long build step, CMake errors, compiler errors. Fixes:
python -m pip install --upgrade pip setuptools wheel“No matching distribution found” or “Unsupported wheel”
python -V). Choose a wheel that supports that version (manylinux/macOS/Windows wheels on PyPI target specific Python versions).Raspberry Pi / ARM
opencv-python-headless first. If unavailable, consider system packages for camera/GUI pieces, or build from source following the OS page linked below.Import works in terminal but fails in IDE
For beginners using Python, PyPI is recommended. Native distribution packages and full source builds are better suited to advanced users with platform‑specific needs. You can still find them on the OS‑specific pages, moved under “Alternatives.”