Skip to content

Install from source

Best option for trying latest patches(maybe experimental), forking for Pull Requests, or automatically installing all prerequisites(with a few exceptions).

Prerequisites

When installing VidGear from source, following are some API specific prerequisites you may need to install manually:

What about rest of the prerequisites?

Any other python prerequisites (Critical/API specific) will be automatically installed based on your OS/System specifications.

Upgrade your pip

It strongly advised to upgrade to latest pip before installing vidgear to avoid any undesired installation error(s).

There are two mechanisms to upgrade pip:

You can use existing pip to upgrade itself:

Install pip if not present
python get-pip.py
py get-pip.py

More details about this script can be found in pypa/get-pip’s README.

python -m pip install pip --upgrade
py -m pip install pip --upgrade

Python also comes with an ensurepip module1, which can easily upgrade/install pip in any Python environment.

python -m ensurepip --upgrade
py -m ensurepip --upgrade

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

If you want to checkout the latest beta testing branch , you can do so with the following commands:

This can be useful if you want to provide feedback for a new feature or bug fix in the testing branch.

DO NOT clone or install any other branch other than testing unless advised, as it is not tested with CI environments and possibly very unstable or unusable.

Installing vidgear with only selective dependencies

Starting with version v0.2.2, you can now run any VidGear API by installing only just 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 on your system:

  • To clone and install bare-minimum vidgear without any dependencies do as follows:

    # clone the repository and get inside
    git clone https://github.com/abhiTronix/vidgear.git && cd vidgear
    
    # checkout the latest testing branch
    git checkout testing
    
    # Install stable release with bare-minimum dependencies
    pip install .
    
  • 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 this for its installation)
    VideoGear Based on CamGear or PiGear backend in use
    ScreenGear dxcam, mss, pyscreenshot, Pillow
    WriteGear FFmpeg: See this doc ➶
    StreamGear 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 -
Windows Installation

If you are using Windows, some of the commands given below, may not work out-of-the-box.

A quick solution may be to preface every Python command with python -m like this:

# Install latest stable release with all Core dependencies
python -m pip install -U .[core]

# Or Install latest stable release with all Core & Asyncio dependencies
python -m pip install -U .[asyncio]

And, If you don't have the privileges to the directory you're installing package. Then use --user flag, that makes pip install packages in your home directory instead:

# Install latest stable release with all Core dependencies
python -m pip install --upgrade --user .[core]

# Or Install latest stable release with all Core & Asyncio dependencies
python -m pip install --upgrade --user .[asyncio]

Or, If you're using py as alias for installed python, then:

# Install latest stable release with all Core dependencies
py -m pip install --upgrade --user .[core]

# Or Install latest stable release with all Core & Asyncio dependencies
py -m pip install --upgrade --user .[asyncio]
# clone the repository and get inside
git clone https://github.com/abhiTronix/vidgear.git && cd vidgear

# checkout the latest testing branch
git checkout testing

# Install latest stable release with all Core dependencies
pip install -U .[core]

# Or Install latest stable release with all Core & Asyncio dependencies
pip install -U .[asyncio]

 


  1. âš  The ensurepip module is missing/disabled on Ubuntu. Use pip method only.