Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'pyrealsense2 by python script in startup (jetson nano) #11387

Closed
PhenonGH opened this issue Feb 2, 2023 · 9 comments

Comments

@PhenonGH
Copy link

PhenonGH commented Feb 2, 2023

ModuleNotFoundError: No module named 'pyrealsense2 by python script in startup (jetson nano)


Required Info
Camera Model D435i
Operating System & Version Ubuntu 18.04
Kernel Version (Linux Only) 4.9.253-tegra
SDK Version 2.53.1
Firmware Version 05.13.00.50
Platform NVIDIA Jetson Nano
Language python 3.6.9
Segment Robot

Hello, I'm having a problem with the pyrealsense2 module. When my Python script is called normally, there are no problems. However, I wanted to build a sort of robot using the Jetson Nano and the camera, so I wanted to put my script into the autostart. Unfortunately, I now always receive the error message: ModuleNotFoundError: No module named 'pyrealsense2'. Additionally, I have discovered that if I run the script with sudo rights, I receive the same error message, but that has never been a real problem for me. I would be very grateful for help, as I am still relatively new to the Linux world.

For the camera installation, I used this: https://github.com/35selim/RealSense-Jetson/blob/main/build_pyrealsense2_and_SDK.sh.

autostart:

[Desktop Entry]
Type=Application
Exec=python3 /home/jetson/My/main.py
Hidden=false
NoDisplay=false
Terminal=true
X-GNOME-Autostart-enabled=true
X-GNOME-Autostart-delay=100

Name[en_US]=v2
Name=v2
Type=Application
Comment[en_US]=

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Feb 2, 2023

Hi @PhenonGH There was a past case at #7861 (comment) that used autostart and they defined their Exec path like this:

[Desktop Entry]
Type=Application
Name=Realsense
Exec=/usr/bin/python3 /home/pi/counter.py

Does your error still occur if you change your Exec path from python3 to /usr/bin/python3

The Python 3 path on a particular computer can be found by using the command which python3

@PhenonGH
Copy link
Author

PhenonGH commented Feb 2, 2023

Thank you for your quick response, unfortunately your solution was not effective and the same error still appears.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Feb 2, 2023

The steps in your build_pyrealsense2_and_SDK.sh build script resemble the list of instructions in the guide at #6964 (comment) for installing librealsense and pyrealsense2 together on Jetson Nano. I cannot see a problem in your script's sequence of commands.

The error ModuleNotFoundError: No module named 'pyrealsense2' may occur if the program cannot find the pyrealsense2 files for some reason. A workaround for this is to place two pyrealsense2 .so files in the same folder location as your project script. The two files to place next to your script are librealsense2.so and pyrealsense2.so.

When the pyrealsense2 wrapper is built for Python 3, the pyrealsense2.so file will be generated with a complex filename based around your Python 3 version number, such as pyrealsense2.cpython-36m-arm-linux-gnueabihf.so - this file should not be renamed and should instead be placed unchanged in the project folder.

Aside from #7861 (comment) the pyrealsense2 wrapper has not been reported by RealSense users as being used with autostart, so I would recommend using the wrapper in the conventional way if possible - the 'called normally' approach.

@PhenonGH
Copy link
Author

PhenonGH commented Feb 2, 2023

Ok it works.

Workaround:
I have copied these files:

pybackend2.cpython-36m-aarch64-linux-gnu.so.2
pybackend2.cpython-36m-aarch64-linux-gnu.so.2.51.1
pyrealsense2.cpython-36m-aarch64-linux-gnu.so
pyrealsense2.cpython-36m-aarch64-linux-gnu.so.2.51
pyrealsense2.cpython-36m-aarch64-linux-gnu.so.2.51.1

from librealsense>build>wrappers>python

into my program folder. I don't know if all the files or only some of them are required, I will try it out sometime.

Many thanks without your help I probably wouldn't have come up with this solution.

The topic can be closed.

@PhenonGH PhenonGH closed this as completed Feb 2, 2023
@MartyG-RealSense
Copy link
Collaborator

You are very welcome, @PhenonGH - it's excellent news that copying the .so files worked for you. Thanks very much for the update!

@TheMuhammadRafay
Copy link

TheMuhammadRafay commented Aug 28, 2024

Hi @MartyG-RealSense Brother, I am having the same issue
Using the Ubuntu 18.04 Bionic (ROS Melodic) on Jetson Nano B01 and Python 3.6.9 on a Depth Camera Intel Realsense D435.
I first tried python script with pyrealsense2 on laptop and it works.
But when I tried on my PC with Jetson Nano, It always give error of ModuleNotFoundError: No module named 'pyrealsense2'.
I have been trying since last week by installing first python 3.6.9 and then downgrading it to python 2.7 but the error still remains.
I have tried several other methods too but This pyrealsense2 error is not being solved.
My these files pyrealsense2.cpython-36m-arm-linux-gnueabihf.so are in the user/local/lib/python3/pyrealsense2 folder.
I don't understand what to its been hectic for the past 1 week.
You both solved this error. Just I want is proper instructions step by step so I can solve this error. Please help me in solving this issue.
WhatsApp Image 2024-08-27 at 12 57 41_8eb2c7d7
WhatsApp Image 2024-08-28 at 12 55 03_7017ae80

@MartyG-RealSense
Copy link
Collaborator

Hi @TheMuhammadRafay Which version of the librealsense SDK are you using, please? Support for Python 3.6 was removed from the SDK in version 2.54.1 onwards.

@TheMuhammadRafay
Copy link

TheMuhammadRafay commented Aug 28, 2024

@MartyG-RealSense I am using the Librealsense SDK 2.55.1 along with the Jetson Nano Jetpack 4.6.5.

@MartyG-RealSense
Copy link
Collaborator

Please try moving the pyrealsense2.cpython-36m-arm-linux-gnueabihf.so file to the same folder that your pyrealsense2 project script is in if you have not done so already, and also move the file librealsense2.so to that folder.

If you cannot find both of these .so files then please check for them in the build > wrappers > Python directory of your librealsense2 source code folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants