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
- bin:
- 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 3 years ago
- Comments: 40 (16 by maintainers)
I had a same problem. These two lines are helped me out:
$sudo apt install --reinstall ros-humble-rclpy$source /opt/ros/humble/setup.bashTry your luck!Also, on your .bashrc file try to source ros directory at the end after all lines.
setcapsolved the problem for me. hereThis will remove extended capabilities from the executable. Change the python version according to your setup.
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.
I’m here because I was using IsaacSim, without ROS2 installed natively. Remove this line from
.bashrcto get ROS2 working again natively:# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$isaac_sim_package_path/exts/omni.isaac.ros2_bridge/humble/libAccording to this, https://docs.ros.org/en/rolling/How-To-Guides/Installation-Troubleshooting.html#import-failing-without-library-present-on-the-system I think we cannot use different version of Python because the Python of ROS2 build different binary file of C extension from the Python of another
Thank you! I was able to solve it by deactivating my anaconda environment (don’t know why but that way my Python interpreter finds
rclpypackage).According to
access("/etc/suid-debug", F_OK), I believe that you changed the/usr/bin/python3.10with ‘+s’ which will erase theLD_LIBRARY_PATH.Please revert it with
sudo chmod -s /usr/bin/python3.10.@squizz617
I’m interested in this issue because it’s almost impossible as the
lddshows that thercl_action.sois 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?