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

RealSense D435i: Python Script Shows 'No Device Connected' While pyrealsense2 Imports Successfully and Viewer Runs #13297

Closed
andrewli1126 opened this issue Aug 28, 2024 · 12 comments

Comments

@andrewli1126
Copy link


Required Info
Camera Model { D435i }
Firmware Version (5.16.0.1)
Operating System & Version { Linux (Ubuntu 22.04 )
Kernel Version (Linux Only) (5.15.136-tegra )
Platform NVIDIA Jetson Orin Nano 8 GB
SDK Version { 2.55.1 }
Language {python 3.10.12}
Segment {Robot}

Issue Description
Hello~
I have successfully installed the SDK packages and run pip3 install pyrealsense2 without any issues. The camera works perfectly with the RealSense Viewer. However, when I try to execute my Python script using the pyrealsense2 wrapper, I can import the module without any errors, but the pipeline fails to start, returning the error: "No device connected."

Steps Taken:

  1. Verified that the RealSense Viewer detects the camera.
  2. Confirmed that pyrealsense2 imports successfully in Python.
  3. Attempted to run minimal code to start the pipeline, but it fails with the "No device connected" error.
  4. Checked for version mismatches between the SDK and the Python wrapper.
  5. Enabled debug logging to capture error messages.
  6. Ensure USB cable and port are 3.0

Could you please assist me in diagnosing this issue? Any guidance or suggestions would be greatly appreciated.
screenshot

@MartyG-RealSense
Copy link
Collaborator

Hi @andrewli1126 Does it make a difference if you launch your Python script in sudo admin permissions mode? For example:

sudo python3 test.py

@andrewli1126
Copy link
Author

Hello @MartyG-RealSense, I tried to run the script using sudo python3, but the camera still wouldn’t start. I also tried executing the code in the bash line by line, and I received the same runtime error.

WhatsApp Image 2024-08-29 at 10 36 07_9dad71d8

@MartyG-RealSense
Copy link
Collaborator

Is the camera still undetected by your Python script if you unplug the camera, wait a couple of seconds and then plug it back in before running your script? An unplug-replug will reset the pipeline.

@andrewli1126
Copy link
Author

@MartyG-RealSense The camera still isn't detected by the Python script after unplugging and replugging. Could this be a problem with the Python wrapper?
I also tried redirecting PYTHONPATH to the site package location, but it didn't work.

@MartyG-RealSense
Copy link
Collaborator

Sometimes the camera will work fine with the Viewer but not with the Python wrapper. There is not a clear reason why the wrapper will work for some users but not for others. Sometimes it could take four unplug-replugs of the camera or more before it is detected.

I suspect that the PYTHONPATH is not the cause of the problem.

Although pip install of the pyrealsense2 wrapper is supported on Arm devices, it usually does not work on Raspberry Pi and Nvidia Jetson boards, so I was surprised that installation completed successfully on your Jetson. I would usually recommend building the pyrealsense2 wrapper from source code on Jetson instead of using pip install pyrealsense2.

@andrewli1126
Copy link
Author

Thank you @MartyG-RealSense :)

The issue was resolved by uninstalling pyrealsense2 and rebuilding the wrapper from source.

@MartyG-RealSense
Copy link
Collaborator

It's excellent news that a source code build of the wrapper succeeded, @andrewli1126 - thanks very much for the update. :)

@MartyG-RealSense
Copy link
Collaborator

Case closed due to solution achieved and no further comments received.

@Boatsure
Copy link

Hello @andrewli1126 @MartyG-RealSense
I face exactly the same issue except that my Jetson Board is Orin NX 16 GB with JetPack 6.0_rev2.
Just for sure:
dose "uninstalling pyrealsense2" means 'pip uninstall pyrealsense2' ?
and "rebuilding the wrapper from source" means means all the procedures from 'mkdir build' to 'sudo make install' ?
I'm confused that is python wrapper part of the librealsense SDK ? And all the saying of "build from source" means building the SDK from source?

@MartyG-RealSense
Copy link
Collaborator

Hi @Boatsure I have never heard of the pip package version of pyrealsense2 being uninstalled that way, but as pip uninstall is a valid command I guess that it must be possible to do so.

Yes, building the wrapper from source means all the procedures from 'mkdir build' to 'sudo make install.
#6964 (comment) has an example of an instruction guide for doing so on a Jetson board. This guide installs both librealsense and pyrealsense2 from source code at the same time.

The pyrealsense2 wrapper is part of the librealsense SDK, but it is not installed by default because not all RealSense users will be using Python.

@Boatsure
Copy link

@MartyG-RealSense Thanks for your reply!
I run 'pip uninstall pyrealsense2' and rebuild from source with '-DBUILD_PYTHON_BINDINGS:bool=true', now all things work fine.

@MartyG-RealSense
Copy link
Collaborator

That's great to hear, @Boatsure - thanks very much for the update about your success!

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