Prebuilt pyrealsense2 packages of the librealsense library for macOS as an addition to the PyPI prebuilt packages by Intel.
To install the prebuilt wheel packages from this repository, run the following command (macOSX librealsense is included):
pip install pyrealsense2-macosxSupported Platforms & Versions
- OS: macOS Catalina* (
10.15), macOS Big Sur* (11), macOS Monterey (12) and higher - Architecture:
Intel (x86_64),Apple Silicon (arm64) - Python:
3.6*,3.7*,3.8,3.9,3.10,3.11,3.12
To use pyrealsense2 in a requirements.txt in combination with pyrealsense2-macosx use the following lines. This will install either the official Windows / Linux version or the MacOSX pre-built wheel package.
pyrealsense2; platform_system == "Windows" or platform_system == "Linux"
pyrealsense2-macosx; platform_system == "Darwin"With the new build pipeline supporting MacOS 12, the binary packages generated by this are universal targeted for x86_64 and amd64. To allow this, we set the MACOSX_DEPLOYMENT_TARGET to 12.
- For Catalina (
10.5) use the older releases like 2.49.0 - For BigSur (
11.0) use the older releases like 2.53.1
# Catalina
pip install pyrealsense2-macosx~=2.49.0
# BigSur
pip install pyrealsense2-macosx~=2.53.1Since 2.50.0 the realsense binaries have to run under sudo on some MacOS to find a device. Otherwise strange errors appear (failed to set power state). This seems to be a bug in the realsense framework and is already discussed in this librealsense2 issue.
Install homebrew and the following packages:
sudo xcode-select --install
brew install cmake pkg-config openssl
brew install --cask powershell
# the vulkan sdk seems to not be needed anymore
# and is deprecated anyways (download error 404)
# brew install apenngrace/vulkan/vulkan-sdk --caskAnd set up a new python virtual environment:
python3.9 -m venv venv
source venv/bin/activateRun the build script in your preferred shell.
pwsh librealsense-python-mac.ps1It is possible to set the tag version to build older releases:
pwsh librealsense-python-mac.ps1 -tag v2.49.0
The prebuild wheel files are copied into the ./dist directory. By default, the dylib is added to the wheel file with the delocate toolkit. It is possible to disable this behaviour for just the python build:
pwsh librealsense-python-mac.ps1 -delocate $false
The buildscript creates binaries which are targeted to arm64 and x86_64. At the moment I could not find a way to tell the wheel package to set a universal tag. For now it is just possible to rename the wheel and change the architecture to the other platform and the packge will work there too.
To install the wheel package just use the default pip install command.
pip install pyrealsense2-2.48.0-cp39-cp39-macosx_11_0_x86_64.whlMIT License - Copyright (c) 2024 Florian Bruggisser