Install the ZED Python API
This section explains how to use the ZED SDK in Python 3 on Windows and Linux platforms.
Getting Started #
The Python API is a wrapper around the ZED SDK which is written in C++ optimized code. We make the ZED SDK accessible from external Python code using Cython.
To start using the ZED SDK in Python, you will need to install the following dependencies on your system:
- ZED SDK (see Installation section)
- Python 3.6+ (x64)
- Cython 0.26+
- Numpy 1.13+
- OpenCV Python (optional)
- PyOpenGL (optional)
Make sure to install Python (x64 version) and the pip package manager. Then install the dependencies via pip in a terminal.
Linux:
python -m pip install cython numpy opencv-python pyopengl
Windows:
py -m pip install cython numpy opencv-python pyopengl
Installing the Python API #
A Python script is available in the ZED SDK installation folder and can automatically detect your platform, CUDA and Python version and download the corresponding pre-compiled Python API package.
📌 Note: On Linux systems, this script can be run automatically when running the SDK installer. Press
Y
if you want to do so:Do you want to install the Python API (recommended) [Y/n] ?
Running the install script #
Windows #
The Python install script is located in C:\Program Files (x86)\ZED SDK\
.
⚠️ Make sure you have admin access to run it in the Program Files folder, otherwise, you will have a
Permission denied
error. You can still copy the file into another location to run it without permissions.
Linux #
The Python install script is located in /usr/local/zed/
.
Run the script:
cd "/usr/local/zed/"
python3 get_python_api.py
-> Downloading to '/usr/local/zed'
Detected platform:
linux_x86_64
Python 3.10
ZED SDK 4.2
-> Checking if https://download.stereolabs.com/zedsdk/4.2/whl/linux_x86_64/pyzed-4.2-cp310-cp310-linux_x86_64.whl exists and is available
-> Found ! Downloading python package into /usr/local/zed/pyzed-4.2-cp310-cp310-linux_x86_64.whl
-> Installing necessary dependencies
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: numpy in /home/walter/.local/lib/python3.10/site-packages (1.23.4)
Defaulting to user installation because normal site-packages is not writeable
Processing ./pyzed-4.2-cp310-cp310-linux_x86_64.whl
Collecting numpy<2.0,>=1.13 (from pyzed==4.2)
Using cached numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)
Collecting cython>=3.0.0 (from pyzed==4.2)
Using cached Cython-3.0.11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.2 kB)
Using cached Cython-3.0.11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB)
Using cached numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)
Installing collected packages: numpy, cython, pyzed
Successfully installed cython-0.29.32 numpy-1.23.4 pyzed-3.8
Done
To install it later or on a different environment run :
python -m pip install --ignore-installed /usr/local/zed/pyzed-4.2-cp310-cp310-linux_x86_64.whl
That’s it! The Python API is now installed. To get started, check out our Tutorials and Samples.
📌 Note: If you are using a virtual environment, make sure to activate it before running the script. Refer to this page for more information.
Troubleshooting #
“Numpy binary incompatibility” #
Traceback (most recent call last):
...
File "__init__.pxd", line 918, in init pyzed.sl
ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C header, got 192 from PyObject
This error usually means Numpy isn’t installed. To install it, simply run these commands :
# On NVIDIA® Jetson (aarch64) cython needs to be installed first since numpy needs to be compiled.
python3 -m pip install cython
python3 -m pip install numpy