[ros-users] [Discourse.ros.org] [Next Generation ROS] Import error No module named 'rclpy._rclpy' cross compiling

Alberto Soragna ros.discourse at gmail.com
Thu Nov 8 02:53:36 UTC 2018



Sorry for resurrecting this old thread, but several links on the web points here even if a solution to the problem is not presented clearly.

As @LanderU pointed out the problem is with the name of the cpython libraries.

To fix the error you have to add the following CMake argument to the cross-compile command:

`-DPYTHON_SOABI="cpython-35m-${TOOLCHAIN_PREFIX}"`

For example TOOLCHAIN_PREFIX=arm-linux-gnueabihf

As for the specific error at the beginning of the thread, Python is looking for a module named `rclpy._rclpy`.
That module is contained in the cpython library located at `ros2_ws/install/rclpy/lib/python3.5/site-packages/rclpy/_rclpy.cpython-35m-x86_64-linux-gnu.so`.

When you are on an ARM processor, that library is not automatically loaded due to its name, where it referes to a different architecture.

However if you inspect the file, you will notice that it has been cross-compiled correctly.

If you manually load the missing module from the library absolute path you will notice that indeed it works.

The CMake variable `PYTHON_SOABI` is responsible of the name of this library, as you can see from https://github.com/ros2/rosidl_python/blob/master/python_cmake_module/cmake/Modules/FindPythonExtra.cmake

For a full example you can refer to [this](https://github.com/alsora/ros2-raspberrypi) repository for RaspberryPi cross-compilation.





---
[Visit Topic](https://discourse.ros.org/t/import-error-no-module-named-rclpy-rclpy-cross-compiling/2463/6) or reply to this email to respond.




More information about the ros-users mailing list