Skip to content

Install using Poetry

Best option for managing VidGear as a dependency in a Poetry-managed project.

VidGear's pyproject.toml is PEP 517/621 compliant, so it can be consumed directly by Poetry.

Don't have Poetry installed?

Follow the official Poetry installation guide before proceeding. You can verify your install with:

poetry --version

Prerequisites

When installing VidGear with Poetry, you need to manually install the following prerequisites:

Critical Prerequisites âš 

  • OpenCV

    Must require OpenCV(3.0+) python binaries installed for all core functions. You can easily install it directly via pip:

    OpenCV installation from source

    You can also follow online tutorials for building & installing OpenCV on Windows, Linux, MacOS and Raspberry Pi machines manually from its source.

    âš  Make sure not to install both pip and source version together. Otherwise installation will fail to work!

    Other OpenCV binaries

    OpenCV maintainers also provide additional binaries via pip that contains both main modules and contrib/extra modules opencv-contrib-python, and for server (headless) environments like opencv-python-headless and opencv-contrib-python-headless. You can also install any one of them in similar manner. More information can be found here.

    pip install opencv-python       
    

API Specific Prerequisites

  • Picamera2

    Required only if you're using Raspberry Pi Camera Modules (or USB webcams) with the PiGear API. Here's how to install Picamera2 python library:

    Using Legacy picamera library with PiGear (v0.3.3 and above)

    PiGear API (version 0.3.3 onwards) prioritizes the newer Picamera2 library under the hood for Raspberry Pi camera modules. However, if your operating system doesn't support Picamera2, you can still use the legacy picamera library. Here's how to easily install it using pip:

    pip install picamera
    

    You could also enforce the legacy picamera API backend in PiGear by using the enforce_legacy_picamera user-defined optional parameter boolean attribute.

    Picamera2 is only supported on Raspberry Pi OS Bullseye (or later) images, both 32 and 64-bit.

    Picamera2 is NOT supported on:

    • Images based on Buster or earlier releases.
    • Raspberry Pi OS Legacy images.
    • Bullseye (or later) images where the legacy camera stack has been re-enabled.
    As of September 2022, Picamera2 is pre-installed on images downloaded from Raspberry Pi. So you don't have to install it manually.
    • On Raspberry Pi OS images, Picamera2 is now installed with all the GUI (Qt and OpenGL) dependencies.
    • On Raspberry Pi OS Lite, it is installed without the GUI dependencies, although preview images can still be displayed using DRM/KMS. If these users wish to use the additional X-Windows GUI features, they will need to run:

      sudo apt install -y python3-pyqt5 python3-opengl
      

    If Picamera2 is not already installed, then your image is presumably older and you should start with system upgrade:

    sudo apt update && upgrade
    

    If you have installed Picamera2 previously using pip, then you should also uninstall this (pip3 uninstall picamera2).

    Thereafter, you can install Picamera2 with all the GUI (Qt and OpenGL) dependencies using:

    sudo apt install -y python3-picamera2
    

    Or, If you DON'T want the GUI dependencies, use:

    sudo apt install -y python3-picamera2 --no-install-recommends
    

    This is NOT the recommended way to install Picamera2.

    However, if you wish to install Picamera2 with all the GUI (Qt and OpenGL) dependencies with pip, use:

    sudo apt install -y python3-libcamera python3-kms++
    sudo apt install -y python3-pyqt5 python3-prctl 
    sudo apt install -y libatlas-base-dev ffmpeg python3-pip
    pip3 install numpy --upgrade
    pip3 install picamera2[gui]
    

    Or, If you DON'T want the GUI dependencies, use:

    sudo apt install -y python3-libcamera python3-kms++
    sudo apt install -y python3-prctl libatlas-base-dev
    sudo apt install -y ffmpeg libopenjp2-7 python3-pip
    pip3 install numpy --upgrade
    pip3 install picamera2
    

 

Installation

Add VidGear to an existing Poetry project:

Adding vidgear with only selective dependencies

Starting with version v0.2.2, you can run any VidGear API by installing only the specific dependencies required by the API in use (except for some Core dependencies).

This is useful when you want to manually review, select and install minimal API-specific dependencies on bare-minimum vidgear from scratch:

  • Add bare-minimum vidgear as follows:

    # Add stable release with bare-minimum dependencies
    poetry add vidgear
    
  • Then, you must install Critical dependencies (if not already):

    # Install opencv (only if not installed previously)
    pip install opencv-python 
    
  • Finally, manually install your API-specific dependencies as required by your API (in use):

    # Just copy-&-paste from table below
    pip install <API-specific dependencies>
    
    APIs Dependencies
    CamGear yt_dlp
    PiGear picamera, picamera2 (see pip install doc for its installation)
    VideoGear Based on CamGear or PiGear or FFGear backend in use
    ScreenGear dxcam, mss, pyscreenshot, Pillow
    WriteGear FFmpeg: See this doc âž¶
    StreamGear FFmpeg: See this doc âž¶
    FFGear FFmpeg: See this doc âž¶
    NetGear pyzmq, simplejpeg
    WebGear starlette, jinja2, uvicorn, simplejpeg
    WebGear_RTC aiortc, starlette, jinja2, uvicorn
    NetGear_Async pyzmq, msgpack, msgpack_numpy, uvloop
    Stabilizer Class -
# Add latest stable release with all Core dependencies
poetry add vidgear[core]

# Or add latest stable release with all Core & Asyncio dependencies
poetry add vidgear[asyncio]

Or, install directly from source in a Poetry-managed environment:

# clone the repository and get inside
git clone https://github.com/abhiTronix/vidgear.git && cd vidgear

# Install it into Poetry's virtualenv with all Core dependencies
poetry install --extras core

# Or with all Core & Asyncio dependencies
poetry install --extras asyncio
Running commands inside Poetry's virtualenv

Use poetry run to execute VidGear-powered scripts without activating the shell:

poetry run python your_script.py

Or spawn a shell inside the virtualenv:

poetry shell