This document lists all system and Python dependencies required for the camera backends.
- Raspberry Pi 5 (or compatible)
- Camera modules (tested with Arducam IMX519)
- Raspberry Pi OS Bookworm (64-bit)
sudo apt-get install -y \
python3-dev \
libcap-dev| Package | Purpose | Required For |
|---|---|---|
python3-dev |
Python development headers | Building Python C extensions |
libcap-dev |
libcap development headers | python-prctl dependency |
sudo apt-get install -y \
python3-libcamera \
python3-kms++| Package | Purpose | Version Tested |
|---|---|---|
python3-libcamera |
Python bindings for libcamera | 0.5.2+125 |
python3-kms++ |
KMS++ Python bindings | 0~git20250807 |
# Already installed on Raspberry Pi OS with camera support
rpicam-apps # Provides rpicam-still commandAll listed in requirements.txt - installed via pip:
pip install -r requirements.txtpicamera2>=0.3.33 # For picamera2 backend
Dependencies of picamera2 (auto-installed):
numpy>=2.4.0- Array operationspillow>=12.1.0- Image processingpiexif>=1.1.3- EXIF metadatasimplejpeg>=1.9.0- Fast JPEG encodingpython-prctl>=1.8.1- Process control (requires libcap-dev)PiDNG>=4.0.9- DNG RAW format support
The picamera2 backend requires access to system-installed libcamera Python bindings, which cannot be installed via pip. The virtual environment must be configured to see system packages:
# Create venv
python3 -m venv .venv
# Link system packages (REQUIRED for picamera2 backend)
echo "/usr/lib/python3/dist-packages" > .venv/lib/python3.11/site-packages/system-packages.pth
# Activate and install
source .venv/bin/activate
pip install -r requirements.txtRun the setup script to handle all dependencies:
./setup_camera_backends.shThis script will:
- ✓ Check system compatibility
- ✓ Install system packages
- ✓ Create/update virtual environment
- ✓ Link system site-packages
- ✓ Install Python dependencies
- ✓ Verify installation
Test that all dependencies are correctly installed:
source .venv/bin/activate
# Test system bindings
python -c "import libcamera; print('libcamera OK')"
# Test backends
python -c "from capture.backends import RpicamBackend, Picamera2Backend; print('Backends OK')"
# Run full test suite
python capture/test_phase2_picamera2.pyFor containerized deployments, the Dockerfile must:
- Install system packages:
RUN apt-get update && apt-get install -y \
python3-dev \
libcap-dev \
python3-libcamera \
python3-kms++ \
rpicam-apps- Grant camera access:
# Add to docker-compose.yml
devices:
- /dev/video0:/dev/video0
- /dev/video1:/dev/video1
privileged: true # Required for camera access- Link system packages in container:
RUN echo "/usr/lib/python3/dist-packages" > \
/app/.venv/lib/python3.11/site-packages/system-packages.ptherror: command 'gcc' failed with exit code 1
Solution: Install build dependencies
sudo apt-get install -y python3-dev libcap-devSolution: Link system packages to venv
echo "/usr/lib/python3/dist-packages" > \
.venv/lib/python3.11/site-packages/system-packages.pthSolution: Add user to video group
sudo usermod -aG video $USER
# Log out and back in- System packages: Follow Raspberry Pi OS updates
- Python packages: Pin versions in requirements.txt
- libcamera: Tied to system package version
- picamera2: Pin to tested version (currently >=0.3.33)