ROS2运行例程报错:无法找到 librclpy_common.so共享库文件【已解决】

在ROS2(foxy/galactic版本)系统中,不管运行什么例程都会报这个错,显示导入错误: librclpy_common.so: 无法打开共享对象文件。报错信息如下:

ImportError: librclpy_common.so: cannot open shared object file: No such file or directory

ImportError: librclpy_common.so: cannot open shared object file: No such file or directory
The C extension '/opt/ros/foxy/lib/python3.8/site-packages/rclpy/_rclpy.cpython-38-aarch64-linux-gnu.so' failed to be imported while being present on the system. Please refer to 'https://index.ros.org/doc/ros2/Troubleshooting/Installation-Troubleshooting/#import-failing-even-with-library-present-on-the-system' for possible solutions

在这里插入图片描述

检查python版本得知,系统的python3版本为Python 3.8.10

python3 --version

检查系统是否正常安装ros-eloquent-rclpy:

dpkg -L ros-foxy-rclpy

ROS2运行例程报错:无法找到 librclpy_common.so共享库文件【已解决】_第1张图片
在ROS论坛查到原因:问题在于:当使用 LD_LIBRARY_PATH 时,LD_LIBRARY_PATH 会被setcap忽略。因此python3.8将无法找到ros库,只能找到python包。

解决办法:
运行以下指令后即可解决问题

sudo setcap -r /usr/bin/python3.8

ROS2运行例程报错:无法找到 librclpy_common.so共享库文件【已解决】_第2张图片

你可能感兴趣的:(ROS2,ubuntu,linux)