Refer to "How to build OpenVINO" in OpenVINO™ developer documentation for general building instructions. For each platform, you can build and install the API as a part of OpenVINO™ Toolkit or as a Python wheel.
Wheels are portable Python packages that are ready to install upon download. They are the commonly used binary distributions in Python as they avoid the compiling of extension modules and associated dependency issues on the user end. As a result, wheels installation is faster and smoother, simplifying the process for both developers and users. The .whl
format is the default preference for pip
when you run a pip install
command.
OpenVINO wheels for various platforms are available on PyPI, enabling you to install OpenVINO™ in your Python distribution or a dedicated virtual environment.
OpenVINO builds two different wheels with separate setup.py
files for openvino
and openvino-dev
. To build the wheels while building the project from source, your cmake
command should include -DENABLE_PYTHON=ON
and -DENABLE_WHEEL=ON
. Once built, the wheels can be found under openvino_install_dir/tools
.
While wheels make installation easier, using wheels for development offers less customization than building from source and exporting PYTHONPATH
and other environment variables to OpenVINO directories. Wheels are usually provided for specific packaged versions and might not contain the most recent changes that are available if you choose to clone the repository and build it yourself.
To learn more about wheels and their use cases, check out the article What Are Python Wheels and Why Should You Care?.
OpenVINO can be built based on specific virtual environments such as venv, virtualenv or pyenv. It is highly recommended to use virtual environments during development. They improve development process and allow better management of Python versions and packages.
Note: Supported Python versions can be found in "System Requirements".
-
First, set up the
pyenv
project. Please follow official instructions of the pyenv project for any additional information. -
Install a desired Python version. Following example will use Python in version 3.10.7. To correctly link libraries, an installed Python version must match OpenVINO™:
- Python with a shared library for a dynamically linked OpenVINO™:
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --verbose 3.10.7
- Python with a static library version for a static build of OpenVINO™:
pyenv install --verbose 3.10.7
-
Create a virtual environment based on the installed Python version:
pyenv virtualenv 3.10.7 ov-py310
-
Activate the environment:
pyenv activate ov-py310
-
Install developer requirements for OpenVINO™ Python API while inside virtual environment:
git clone https://github.com/openvinotoolkit/openvino.git cd openvino git submodule update --init --recursive pip install -r src/bindings/python/requirements.txt pip install -r src/bindings/python/requirements_test.txt
If
-DENABLE_WHEEL=ON
flag is present incmake
command, additionally install wheel requirements:pip install -r src/bindings/python/wheel/requirements-dev.txt
-
Add following flags to the main
cmake
command to use specific virtual environment (requires cmake 3.16 and higher):-DPython3_EXECUTABLE=/home/user/.pyenv/versions/3.10.7/bin/python
-
Follow the rest of building and installation steps from "How to build OpenVINO" developer documentation.
For details please refer to Python requirements and version constraints management.
Follow instructions in How to test OpenVINO™ Python API? to verify the build.