Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Setting Up a Computer Vision Environment
Before writing Computer Vision code you need a working Python environment with the right libraries installed. This topic walks you through setup from scratch.
10 min•By Priygop Team•Updated 2026
What You Need
To start coding Computer Vision in Python you need:
- 1Python 3.8 or newer
- 2OpenCV (cv2): the main image processing library
- 3NumPy: for numerical operations on image arrays
- 4Matplotlib (optional): for displaying images in Jupyter notebooks
You will also want a code editor. VS Code is recommended because it has good Python support, a built-in terminal, and free extensions for Jupyter notebooks.
Diagram
Loading diagram…
Machine Learning follows a structured pipeline from data to deployment
Installation Commands
Installation Commands
# Open your terminal and run these commands:
# Install OpenCV (full version with extra modules)
pip install opencv-python
# Or install the headless version (for servers without display)
# pip install opencv-python-headless
# Install NumPy (usually installed with OpenCV, but to be sure)
pip install numpy
# Install Matplotlib (for Jupyter notebook display)
pip install matplotlib
# Verify installations
python -c "import cv2; print('OpenCV version:', cv2.__version__)"
python -c "import numpy as np; print('NumPy version:', np.__version__)"
# Expected output:
# OpenCV version: 4.x.x
# NumPy version: 1.x.xVerifying the Setup
Verifying the Setup
# verification.py — run this to confirm everything works
import cv2
import numpy as np
print("✓ OpenCV installed:", cv2.__version__)
print("✓ NumPy installed:", np.__version__)
# Create a simple test image in memory
test_image = np.zeros((100, 100, 3), dtype=np.uint8)
test_image[25:75, 25:75] = [0, 255, 0] # Green square
print("✓ Can create images:", test_image.shape)
print("✓ Setup complete — you are ready for Computer Vision!")