Based on contributions by ThomasPSluijs.
The prebuilt pyrealsense2 wheels on PyPI don’t support the Raspberry Pi’s ARM architecture, so on a Raspberry Pi 5 running Ubuntu you need to build librealsense (Intel’s RealSense SDK) and its Python bindings from source. This how-to walks through that build.
What you need
- A Raspberry Pi 5 running Ubuntu (these steps were tested with the setup producing Python 3.12 bindings, i.e. a recent Ubuntu release).
- A user account with
sudoaccess. - An Intel RealSense camera (unplug it before starting the driver patching steps).
Steps
1. Update the system
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
Make sure you’re on the latest stable kernel before continuing.
2. Install build dependencies
Core packages needed to build the librealsense binaries and kernel modules:
sudo apt-get install libssl-dev libusb-1.0-0-dev libudev-dev pkg-config libgtk-3-dev
Build tools:
sudo apt-get install git wget cmake build-essential
Packages for the Linux backend and development environment. Unplug any connected RealSense camera before running this:
sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev at
3. Get librealsense
Either clone the repository:
git clone https://github.com/IntelRealSense/librealsense.git
or download and unzip the latest stable version from the master branch: librealsense master.zip
4. Set up udev rules
From the librealsense root directory:
cd librealsense
./scripts/setup_udev_rules.sh
You can remove these permissions later with ./scripts/setup_udev_rules.sh --uninstall.
5. Patch and build the kernel modules
Pick the script matching your kernel:
# Ubuntu 20/22 (focal/jammy) with LTS kernel 5.13 or 5.15
./scripts/patch-realsense-ubuntu-lts-hwe.sh
# Ubuntu 18/20 with an LTS kernel older than 5.13
./scripts/patch-realsense-ubuntu-lts.sh
6. Build the librealsense2 SDK
From the librealsense root directory:
mkdir build && cd build
Run the initial cmake configure step. The default build produces the core shared object and unit-test binaries in Debug mode; add -DCMAKE_BUILD_TYPE=Release for an optimized build.
cmake ../
To also build the demos and tutorials:
cmake ../ -DBUILD_EXAMPLES=true
On a system without OpenGL or X11, build textual examples only:
cmake ../ -DBUILD_EXAMPLES=true -DBUILD_GRAPHICAL_EXAMPLES=false
Then build and install:
sudo make uninstall && make clean && make && sudo make install
7. Build the pyrealsense2 Python bindings
Re-run cmake with the Python bindings flag, then build:
cmake ../ -DBUILD_PYTHON_BINDINGS:bool=true -DPYTHON_EXECUTABLE=/usr/bin/python3
make -j4
sudo make install
8. Copy the built libraries into your project
The build produces librealsense2.so and a pyrealsense2.cpython-<version>-<arch>-linux-gnu.so file (the exact filename depends on your Python version and architecture, for example pyrealsense2.cpython-312-aarch64-linux-gnu.so on Python 3.12/ARM64).
cd librealsense/build/Release
Check: on a standard Unix Makefiles build (the default for this guide), the compiled
.sofiles often end up directly inbuild/rather than in abuild/Releasesubdirectory — that subdirectory is more typical of multi-configuration generators. Ifbuild/Releasedoesn’t exist, look directly inbuild/.
Copy both files into your project folder:
cp -L librealsense2.so {destination}
cp -L pyrealsense2.cpython-312-aarch64-linux-gnu.so {destination}
(replace the filename with whatever your build actually produced, and {destination} with your project’s folder).
You now have pyrealsense2 available on your Raspberry Pi 5. See How to grab, save and filter depth images with Intel RealSense in Python for how to grab, save and filter images once it’s installed.
Related
Rewritten and consolidated (Sept 2026) from the original student how-to’s: How to setup the intel RealSense software and pyrealsense2 library in Ubuntu on a raspberryi pi 5.