Pick the right Python package
- opencv-python — standard wheels with GUI and video I/O; good default for desktops.
- opencv-contrib-python — includes extra modules (contrib) such as xfeatures2d; slightly larger.
- opencv-python-headless — no GUI; ideal for servers/CI where you don't need highgui/video modules.
When to pick each
- Desktop apps, camera/video preview → opencv-python.
- Need SIFT/SURF-like features or contrib modules → opencv-contrib-python.
- Server/CI or no display/audio → opencv-python-headless.
Virtual environments (recommended)
Keep your global Python clean and avoid conflicts by using isolated environments.
venv (built-in)
- Create a new venv in your project folder.
- Activate it in your terminal.
- Install the desired OpenCV package.
Conda (Anaconda/Miniconda)
- Create a new conda environment with your target Python version.
- Install via pip inside conda or try conda-forge if available.
- Verify versions of numpy and OpenCV are compatible.
Common Windows pitfalls
- Conflicting numpy: update numpy before installing OpenCV if you see import errors.
- Multiple Python installations: ensure your IDE uses the same interpreter where you installed OpenCV.
- Camera not opening: close other apps using the webcam and test with a simple capture script.
- 32-bit vs 64-bit: use 64-bit Python on 64-bit Windows.