Skip to content

Workbench article

OpenCV Environment Setup

2. OpenCV Environment Setup

Don't just pip install opencv-python and hope for the best. Version management is critical because OpenCV APIs change between major versions (like the findContours return values in v3 vs v4).

2.1 Virtual Environments

I strongly recommend using venv or conda. Keeping your vision environment isolated prevents "DLL Hell" and dependency conflicts.

python -m venv cv_env
source cv_env/bin/activate  # Linux
cv_env\Scripts\activate   # Windows

2.2 Installing the Right Package

💡 Pro Tip: Use opencv-contrib-python if you need advanced algorithms like SIFT or SURF. These are in the "contrib" module for licensing/stability reasons but are essential for many R&D tasks.