Skip To Main Content
Support Knowledge Base

How to Build the Open-Source OpenVINO™ Toolkit for Linux* from Source with the Python* API Wrapper

Content Type: Install & Setup   |   Article ID: 000057448   |   Last Reviewed: 06/17/2025

To use Python* with the open-source OpenVINO™ toolkit for Linux*, you must install Python* 3.9 - 3.12, and then build the toolkit by specifying the correct Python version in the CMake command line.

If you do not explicitly specify a Python version, CMake picks up the system-level Python version, which is 2.7, and your Python scripts will not work.

Note

The instructions below assume you have already installed Python*.

  1. Build from source.

    Refer to the Building for Linux* instructions for more detailed steps.

    $ git clone https://github.com/openvinotoolkit/openvino.git
    $ cd openvino
    $ git submodule update --init --recursive
    $ chmod +x install_build_dependencies.sh
    $ ./install_build_dependencies.sh
    $ mkdir build && cd build

    $ python3 -m pip install -r ../src/bindings/python/requirements.txt
    $ python3 -m pip install -r ../src/bindings/python/wheel/requirements-dev.txt

     

    Note

    In the CMake command line below, substitute 3.12 with your version of Python*. The location and version of Python depends on the architecture and operating system.

    It is recommended to disable the oneAPI environment before compiling OpenVINO from source on Linux, as it may cause build failures.

     

    $ cmake -DCMAKE_BUILD_TYPE=Release \
    -DENABLE_PYTHON=ON \
    -DPYTHON3_EXECUTABLE=/usr/bin/python3.12 \
    -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.12.so \
    -DPYTHON_INCLUDE_DIR=/usr/include/python3.12 ..
    $ make --jobs=$(nproc --all)

     
  2. Export environment variables.

    After the build process finishes, export the environment variables:

    $ export PYTHONPATH=<openvino_repo>/bin/intel64/Release/python:<openvino_repo>/tools/ovc:$PYTHONPATH$ export LD_LIBRARY_PATH=<openvino_repo>/bin/intel64/Release:$LD_LIBRARY_PATH$ export PATH=<openvino_repo>/tools/ovc/openvino/tools/ovc:$PATH
    $ export PYTHONPATH=$PYTHONPATH:/~/<openvino_repo>/bin/intel64/Release/python_api/python3.12/
    $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/openvino/bin/intel64/Release/

     
  3. Test the build. Check that you correctly built the Python* wrapper by running the following script to import Core:

    $ python3.12

    >>> import openvino as ov
    >>> core = ov.Core()

If you can successfully import Core, you have correctly built the OpenVINO™ toolkit with the Python wrapper.

Related Products

This article applies to 1 products.