View my account

Raspberry Pi ModuleNotFoundError: No module named 'pyrealsense2'

Comments

51 comments

  • MartyG

    Cnorton  The official Raspberry Pi documentation suggests a couple of other Windows tools to write an image to SD card and instructions for doing the write for each tool.

    https://www.raspberrypi.org/documentation/installation/installing-images/windows.md 

    In the guide where Intel provide a pre-made Pi 4 image that includes librealsense, they use balenaEtcher.

    https://dev.intelrealsense.com/docs/open-source-ethernet-networking-for-intel-realsense-depth-cameras#section-2-3-preparing-the-sd-card 

    0
    Comment actions Permalink
  • Cnorton

    MartyG I'm trying to make an image from my MicroSD card to send to Shane Huston since I have a working pyrealsense installation working on Raspbian. Not trying to write any images.

    0
    Comment actions Permalink
  • MartyG

    Cnorton  You can clone the SD card contents onto a PC with Win32 Disk Imager.

    https://www.howtogeek.com/341944/how-to-clone-your-raspberry-pi-sd-card-for-foolproof-backup/ 

    The problem is how to put the card image online for Shane Huston  to download.  You may have to register with an online cloud storage service such as Google Drive to host such a large file, and upload the cloned image to it.

    https://www.google.com/drive/ 

     

    0
    Comment actions Permalink
  • Shane Huston

    MartyX Grover I think he already mentioned he's trying to use Win32 Disk Imager but was having hardware errors.

     

    Cnorton what kind of errors are you seeing? I was able to create an image from my microSD using Win32 Disk Imager. Here is a picture in case it's helpful to see the settings I used (basically default I think)

    0
    Comment actions Permalink
  • Cnorton

    Shane Huston I get the error below

    0
    Comment actions Permalink
  • Shane Huston

    Strange. No sweat if you can't get the img read working. It looks like I may have made some progress. I am able to run some example realsense python scripts now, but only via terminal commands. Cnorton have you been able to run any from the desktop, i.e. in Thonny? Or are you only testing in terminal?

    It seems that my Thonny/desktop seems to want to default to python3 while in terminal it defaults to python2 and works. If in Thonny or using python3 in terminal, I get the following error:

     

    ImportError: /home/realsense/Desktop/pyrealsense2.so: undefined symbol: _Py_ZeroStruct

     

    When running with "python" or "python2" in terminal, the example scripts I've tested run fine. I do need to have the librealsense2 and pyrealsense2 files next to them to work, so perhaps my PATH still isn't working correctly.

    0
    Comment actions Permalink
  • Cnorton

    I'll keep trying to get the image file because its good to have as a backup. 

    I run everything in the terminal, although if the paths are the same they should work the same. Have not seen that error so I'm not sure what would fix that. The command which python3 tells you the path where python3 is located. I think the correct location is: /usr/bin/python3

    Installation problems are the worst, so I'll let you know when I can make an image.

    0
    Comment actions Permalink
  • Shane Huston

    Thanks for your help with this. It looks like Thonny only supports Python3 and up. Are you running your scripts with python2 or 3? Just wondering if I should be using python3 for any reason. I have seen posts saying that python2 is officially retired.

    0
    Comment actions Permalink
  • Cnorton

    For some reason copying my MicroSD card to another and then reading that with Win32 worked. Although the image is 14G, I'll upload it and send you a link to it when its ready.

    0
    Comment actions Permalink
  • Briandinh2307

    I tried copy all the '*.so' files into the folder same as script and it worked. So there are 6 '*.so' files. 3 for librealsense and 3 for pyrealsense2. And follow all the steps here of course https://github.com/acrobotic/Ai_Demos_RPi/wiki/Raspberry-Pi-4-and-Intel-RealSense-D435

    Been stuck with this for 3 days straight. The first time I tried to install it, I got the error "pyrealsense2" has no attribute "pipeline". Didn't know how to fix it so I re-installed everything and got the problem No module named 'pyrealsense2' instead. But copy all the '*.so' files like I said above and it worked for me with python3.

    Well... not really. I'm trying to run the camera on the Raspberry pi 3 with only USB 2.0 and got this error:

    pipeline.start(config)
    RuntimeError: Couldn't resolve requests

    I guess it's some resolution and framerate not compatible with USB 2.0. Would appreciate if anyone knows how to fix it

    1
    Comment actions Permalink
  • MartyG

    Briandinh2307  Thanks so much for your advice!

    Yes, the 400 Series cameras have much more limited resolution and FPS modes available on a USB2 connection due to the lower bandwidth on such a connection compared to USB3 (on which the camera's full capabilities can be accessed).  I hope that the discussion in the link below about a RealSense user who had the same error will be helpful.

    https://support.intelrealsense.com/hc/en-us/community/posts/360033625313-Is-it-possible-to-use-the-PyRealSense2-wrapper-using-a-USB2-0-port- 

     

     

     

    0
    Comment actions Permalink
  • Briandinh2307

    Thanks for the quick reply,

    Just experienced with it. Seems like I can only output the depth stream with this configuration: config.enable_stream(stream.depth, 640, 480, rs.format.z16, 30)

    The infrared and rgb sensors will not work with that configuration. I don't know about other configuration but this is enough to convince me to buy a raspberry pi 4. Hopefully it will arrive within this week. 

    1
    Comment actions Permalink
  • MartyG

    Thanks again for the detailed feedback   :)  Please let us know how you get on with the Pi 4.

    0
    Comment actions Permalink
  • Begaiym Kudainazarova

    Hi MartyX Grover

    I am trying to set up the pyrealsense2 library for the Raspberry Pi 4. I have a D435i. I was able to install the RealSense-viewer and make it work. However when it comes to a python code it cannot find pyrealsense2. I tried to looking for pyrealsense2.so files in /library/build but I couldn't find it. It seems like it is not there at all, however librealsense2.so files are there. What the problem might be in my case?

    0
    Comment actions Permalink
  • MartyG

    Hi Begaiym Kudainazarova  When building the pyrealsense2 wrapper for Python 3, pyrealsense2.so will have a complex auto-generated filename that is partly based on the Python 3 version that you have installed on your computer. For example, if the computer is using Python 3.5 then the auto-generated filename may be something like pyrealsense2.cpython-35m-arm-linux-gnueabihf.so - with the '35m' part referring to the Python 3 version number.

    The easiest way to identify the file that you need is to look for a filename that starts with 'pyrealsense2' and ends in '.so', such as pyrealsense2.cpython-35m-arm-linux-gnueabihf.so

    0
    Comment actions Permalink
  • Begaiym Kudainazarova

    Hi MartyX Grover, thanks a lot for your response. Yeah I know what you mean, since I have installed it previously on my Mac computer before and I saw those files in /librealsense/build/wrapper/python. But this time I cannot see any files with .so extension, only pyrealsense2....cmake. That's why I was very confused because I couldn't find any .so files with pyrealsense2 names. 

    0
    Comment actions Permalink
  • MartyX Grover

    If you cannot find .so files, can you confirm please that your /librealsense/build/wrappers/python does not look like the Pi one below please?

     

    Also, can you describe the installation method that you used to install librealsense and pyrealsense2 on your Pi.

     

    0
    Comment actions Permalink
  • Begaiym Kudainazarova

    MartyG  Yes, my /librealsense/build/wrapper/python file does not look like that. I only have a Cake folder and a few other CMake files. 

    I followed this link to install the librealsense, and didn't get any error during the installation. 

    0
    Comment actions Permalink
  • MartyX Grover

    Which protobuf version did you use, please?  The Acrobotic guide for Pi 4 and Raspberry Pi OS (formerly Raspbian) uses protobuf version 3.10.0.  Some RealSense users found though that they had a smoother build experience with more recent versions such as 3.14.0 as they had issues with 'autogen.sh' when using 3.10.0 or earlier.

     

    If the pyrealsense2 wrapper is able to find the computer's Python installation using the defined PYTHONPATH then it should not be necessary to find the two .so files and place them in the same folder location as your Python project script.  

     

    Also, which Raspberry Pi OS version are you using - Buster or Bullseye?

    0
    Comment actions Permalink
  • Begaiym Kudainazarova

    I am using Raspberry pi Buster. 

    I defined a python path during the installation and since I am not using any environments and other versions of python I don't think there should be a problem with the PYTHONPATH. However I cannot find a pyrealsense2 library even in the dist-packages in python3 root, and I still cannot import it. Should I reinstall the whole thing again using protobuf 3.14.0? Because I tried uninstalling protobuf 3.10.0 and reinstalling it with the version you mentioned but it didn't;t solve the problem, so should I reinstall librealsense and  as well? 

    0
    Comment actions Permalink
  • MartyX Grover

    Sometimes doing a complete wipe and reinstall (including reinstalling the OS) can suddenly resolve a problem if everything else that has been tried to resolve that problem has failed. 

    0
    Comment actions Permalink

Please sign in to leave a comment.