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

Pyrealsense no device connected #13723

Open
Aterox-os opened this issue Jan 29, 2025 · 11 comments
Open

Pyrealsense no device connected #13723

Aterox-os opened this issue Jan 29, 2025 · 11 comments

Comments

@Aterox-os
Copy link

Hello,
I recently started using my D435 with my M2 Macbook. I had a lot of issues with the RealSense viewer ( #13640) but got it working through parallels which works for now since I actually just need pyrealsense. I tried running the default python test:

import pyrealsense2 as rs
pipe = rs.pipeline()
profile = pipe.start()
try:
  for i in range(0, 100):
    frames = pipe.wait_for_frames()
    for f in frames:
      print(f.profile)
finally:
    pipe.stop()

But after some time I get the following error:

Traceback (most recent call last):
  File "/Users/finn/Desktop/pyrealsense/main.py", line 3, in <module>
    profile = pipe.start()
RuntimeError: No device connected

I tried running rs-enumerate-devices but it says that there is no camera connected. If I run system_profiler SPUSBDataType the output is:

2025-01-29 21:30:10.581 system_profiler[21985:135905] SPUSBDevice: IOCreatePlugInInterfaceForService failed 0xe00002be
USB:

    USB 3.1 Bus:

      Host Controller Driver: AppleT8112USBXHCI

    USB 3.1 Bus:

      Host Controller Driver: AppleT8112USBXHCI

        Intel(R) RealSense(TM) Depth Camera 435 :

          Product ID: 0x0b07
          Vendor ID: 0x8086  (Intel Corporation)
          Version: 50.cb
          Manufacturer: Intel(R) RealSense(TM) Depth Camera 435 
          Location ID: 0x00100000

So the camera is connected and recognised by macOS.
I also tried running my script with sudo but then I get the following error:

Traceback (most recent call last):
  File "/Users/finn/Desktop/pyrealsense/main.py", line 1, in <module>
    import pyrealsense2 as rs
  File "/Users/finn/Desktop/pyrealsense/.venv/lib/python3.13/site-packages/pyrealsense2/__init__.py", line 2, in <module>
    from .pyrealsense2 import *
ImportError: dlopen(/Users/finn/Desktop/pyrealsense/.venv/lib/python3.13/site-packages/pyrealsense2/pyrealsense2.cpython-313-darwin.so, 0x0002): Library not loaded: @rpath/librealsense2.2.56.dylib
  Referenced from: <0B5AC2F3-B89A-37B4-BEF2-DB8017891ED4> /Users/finn/Desktop/pyrealsense/.venv/lib/python3.13/site-packages/pyrealsense2/pyrealsense2.2.56.3.cpython-313-darwin.so
  Reason: no LC_RPATH's found

I am running version 2.56.3 and build it manually. I think it's a problem with the permission but I could find anything online on how to resolve the issue. Has someone solved the problem?

@MartyG-RealSense
Copy link
Collaborator

Hi @Aterox-os It sounds as though the camera works at first and then later disconnects and becomes unavailable. Is that what is happening, please?

Are you using a USB C to C cable on your Mac? If you are then these can have more problems with RealSense cameras than a USB A to C cable like the official 1 meter one supplied with the camera?

@Aterox-os
Copy link
Author

I am not sure if the camera disconnects. I can see that macOS recognizes it but the librealsense tools can't. If I keep running system_profiler SPUSBDataType while the program tries to connect to the camera its still visible. So I would say that it is disconnecting. I am using a 3rd party USB c to USB c cable since my mac doesnt have a USB a port. I currently dont have a USB c to USB a cable lying around since I bought the camera second hand without a cable. I can buy a USB a cable and try using it with a adapter.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Jan 30, 2025

Thanks very much for the update.

If the camera is initially detected when the script starts and then disconnects, that could also be a symptom of insufficient power being provided to the camera by the USB system to enable the streams when the profile = pipe.start() line of the script is reached.

I look forward to your next report. Good luck!

@Aterox-os
Copy link
Author

Ok so I actually found a cable and I am clueless now. If I use the USB C to USB A cable with an adapter I get a segmentation fault??? I also tried using a different adapter but it's the same result. Any ideas?

@MartyG-RealSense
Copy link
Collaborator

What method did you use to install pyrealsense2, please?

There is a pre-built package of pyrealsense2 for MacOS created by a RealSense community member that can be found at the link below.

https://github.com/cansik/pyrealsense2-macosx

@Aterox-os
Copy link
Author

I tried to build it manually with the correct make flag and install it in my venv with pip. Both method didn't work. I installed the prebuild package in venv. Is it correct that the import is still pyrealsense2? Because if it is then it doesn't work for me. I still get the error that no device was detected.

@MartyG-RealSense
Copy link
Collaborator

Yes, usually the line is import pyrealsense2 as rs

However, on some computers it is necessary to use import pyrealsense2.pyrealsense2 as rs

@Aterox-os
Copy link
Author

I tried it still no device connected.

@MartyG-RealSense
Copy link
Collaborator

Do you get the same message about no device connected if you try running other pyrealsense2 example scripts, such as the tutorial one here:

https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/python-tutorial-1-depth.py

@Nyanziba
Copy link

Nyanziba commented Jan 31, 2025

@MartyG-RealSense
I encountered same error as @Aterox-os . I use pyrealsense2-python https://github.com/cansik/pyrealsense2-macosx/releases/tag/macosx-v2.56.1-beta but the example scripts won't run. The console just shows
No device connected .
After I ran sudo realsense-viewer and then ran their example scripts, The console shows failed to set power state

@MartyG-RealSense
Copy link
Collaborator

Hi @Nyanziba Some Mac users have found that the realsense-viewer will sometimes be able to eventually start if the sudo realsense-viewer launch command is repeated multiple times (four or more).

The current theory for the problems with using RealSense cameras on Mac is that it was caused by a change by Apple in their USB policy. It is discussed at #11815 (comment)

My Intel RealSense colleagues welcome RealSense Mac users investigating the problems, discussing it amongst themselves and providing feedback that may help towards improving Mac compatibility.

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