Jetson nano AttributeError: module 'pyralesense2' has no attribute 'pipeline' step on the hole

A vision project requires the jetson nano computing platform and intel realsense sr300 camera. We need to call it in python. After understanding, it can be configured in the following steps.
1: Install various dependent packages and check the corresponding versions
2: Download librealsense and compile build (this step is very important. Bloggers have repeated it many times before they succeed)
3: Download pyrealsense2

1. Install dependent packages

First of all, cmake requires a version greater than 3.12. At first, I failed to build. Later, I found that the reason for the camke version is jetpack4.0 on the jetson nano official website The cmake version of 6 is too low. Upgrade it first. Here are the steps

2. tar xpvf cmake-3.13.0.tar.gz cmake-3.13.0/
3. cd cmake-3.13.0/
4. ./bootstrap --system-curl
5. make -j6
6. echo 'export PATH=/home/nvidia/cmake-3.13.0/bin/:$PATH' >> ~/. bashrc
7. source ~/.bashrc

Then install some dependency packages. This can also be done in the second step. This should be available in the official website tutorial

sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install -y --no-install-recommends \
    python3 \
    python3-setuptools \
    python3-pip \

sudo apt-get install -y git libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev

sudo apt-get install -y libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev

2. Download librealsense

Since my Ubuntu version is 18.04, it supports librealsense sdk2, so the version I choose here is librealsense 2.38 1 (without the latest version, I'm afraid there will be some problems with the latest version)
Here are all versions
There will be device types supported by each version, required constraints, etc. you can view them by yourself.
After downloading the source code, unzip it and transfer it to the jetson nano with xftp and other software
Then I try to install it according to the installation tutorial on the official website and the installation tutorial on a website
After the installation, I found no problem in the function test prompted in the installation website, but the problem shown in the title will appear when calling after the installation of pyrealsense2:

AttributeError: module 'pyrealsense2' has no attribute 'pipeline'

Bloggers have also been troubled by this problem for many days. They have searched a lot in the issue in the github of librealsense and tried a lot, but they are not very good. But in the end, I found some inspiration and found the problem. The problem occurs during the build process when librealsense is installed.
Originally, I have been build ing according to the second link above, that is, as shown in the figure

mkdir build
cd build
These two steps have not changed much
The following step needs to be changed. You need to associate python with librealsense so that some files can be generated during compilation. The commands are as follows


Mainly DPYTHON_EXECUTABLE=/usr/bin/python3.6 this one, add it and do it again

sudo make uninstall
sudo make clean
make -j4
sudo make install

Then we'll go back to the Adding environment variables to bashrc

export PATH=$PATH:~/.local/bin
export PYTHONPATH=$PYTHONPATH:/usr/local/lib
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/pyrealsense2

3. Install pyrealsense2

If you use jetson nano, remember that the Ubuntu architecture is aarch64, so you must install the version with aarch64 suffix when installing third-party libraries or other software, otherwise you can't install it. The same is true for pyrealsense 2. At first, I directly used PIP install pyrealsense 2, but I always reported that I couldn't find a suitable version, Then I went to the official website to download the installation package for offline installation, but the installation failed. Later, I found the problem of aarch64. This version is to be downloaded here

pip install pyrealsense2-aarch64 the installation is successful. There is no problem with the function test. Finally, it is over.

Keywords: Python Ubuntu Computer Vision

Added by Satanas on Fri, 17 Dec 2021 04:30:56 +0200