rclpy: _rclpy_pybind11.cpython-310-x86_64-linux-gnu.so failed to be imported while being present on the system

Bug report

Required Info:

  • Operating System: Ubuntu 22.04
  • Installation type: Tried both binary and source installation
  • Version or commit hash:
    • bin: ros-humble-rclpy/jammy,now 3.3.8-2jammy.20230623.051015 amd64 [installed,automatic]
    • src: 76212669
  • DDS implementation: Fast-DDS (default)
  • Client library (if applicable): rclpy

Steps to reproduce issue

  • Binary installation:
$ source /opt/ros/humble/setup.sh
$ python3 -c "import rclpy"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 49, in <module>
    from rclpy.signals import install_signal_handlers
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/signals.py", line 15, in <module>
    from rclpy.exceptions import InvalidHandle
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/exceptions.py", line 15, in <module>
    from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/impl/implementation_singleton.py", line 32, in <module>
    rclpy_implementation = import_c_library('._rclpy_pybind11', package)
  File "/opt/ros/humble/lib/python3.10/site-packages/rpyutils/import_c_library.py", line 39, in import_c_library
    return importlib.import_module(name, package=package)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: librcl_action.so: cannot open shared object file: No such file or directory
The C extension '/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/_rclpy_pybind11.cpython-310-x86_64-linux-gnu.so' failed to be imported while being present on the system. Please refer to 'https://docs.ros.org/en/{distro}/Guides/Installation-Troubleshooting.html#import-failing-even-with-library-present-on-the-system' for possible solutions

$ file /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/_rclpy_pybind11.cpython-310-x86_64-linux-gnu.so
/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/_rclpy_pybind11.cpython-310-x86_64-linux-gnu.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=7a13e46bccf18deb10a3cfdb76b436aa3856fdda, stripped
  • Source installation:
$ source ~/ros2_humble/install/setup.sh
$ python3 -c "import rclpy"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/seulbae/ros2_humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 49, in <module>
    from rclpy.signals import install_signal_handlers
  File "/home/seulbae/ros2_humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/signals.py", line 15, in <module>
    from rclpy.exceptions import InvalidHandle
  File "/home/seulbae/ros2_humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/exceptions.py", line 15, in <module>
    from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
  File "/home/seulbae/ros2_humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/impl/implementation_singleton.py", line 32, in <module>
    rclpy_implementation = import_c_library('._rclpy_pybind11', package)
  File "/home/seulbae/ros2_humble/build/rpyutils/rpyutils/import_c_library.py", line 39, in import_c_library
    return importlib.import_module(name, package=package)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: librcl_action.so: cannot open shared object file: No such file or directory
The C extension '/home/seulbae/ros2_humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/_rclpy_pybind11.cpython-310-x86_64-linux-gnu.so' failed to be imported while being present on the system. Please refer to 'https://docs.ros.org/en/{distro}/Guides/Installation-Troubleshooting.html#import-failing-even-with-library-present-on-the-system' for possible solutions

$ file /home/seulbae/ros2_humble/build/rclpy/test_rclpy/_rclpy_pybind11.cpython-310-x86_64-linux-gnu.so
/home/seulbae/ros2_humble/build/rclpy/test_rclpy/_rclpy_pybind11.cpython-310-x86_64-linux-gnu.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=521156ac1b623401f2b012c6dcece989048e6273, not stripped

Expected behavior

rclpy successfully imported.

Actual behavior

Import failure.

Additional information

I’m not sure what’s causing this issue. A ROS 2 scripts on my machine that worked before suddenly stopped working, and it turned out to be a import failure. Also, the trobleshooting guide in the error message seems to be only for Windows. Thank you.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 27 (15 by maintainers)

Most upvoted comments

I finally managed to solve the problem and wrote a blog post about it in Korean.

https://du-sungchan-24k.tistory.com/37

In summary, you need to directly inject this into your pycharm.sh script.

. /opt/ros/humble/setup.sh’ If installed via Jetbrain Toolbox, your pycharm.sh will be located at

‘/home/{USER_NAME}/.local/share/JetBrains/Toolbox/apps/{pycharm_version}/bin/pycharm.sh’. For Jetbrain Remote Development, pycharm.sh is in

‘/home/{USER_NAME}/.cache/JetBrains/RemoteDev/dist/{cached_pycharm_version}/bin/pycharm.sh’. The same applies to CLion and IntelliJ.

@squizz617

I’m interested in this issue because it’s almost impossible as the ldd shows that the rcl_action.so is found.

Could you run the command strace python3 -c "import rclpy" > /tmp/failed-to-import-rclpy.txt 2>&1, and then upload the log /tmp/failed-to-import-rclpy.txt?