Import error No module named 'rclpy._rclpy' cross compiling


I am cross compiling ros2 beta2 for a ARM platform. I get the source . ./ done and after I try to launch the python talker but rclpy._rclpy cannot be imported. The default Python version is Python 3.5.

The talker written with C++ works perfect.

I also tried to update the rclpy repo to the latest version, and I am getting the same error.

root@host:/opt/ros2/# /opt/ros2/lib/demo_nodes_py/talker
Traceback (most recent call last):
  File "/opt/ros2/lib/demo_nodes_py/talker", line 9, in <module>
    load_entry_point('demo-nodes-py==0.0.0', 'console_scripts', 'talker')()
  File "/usr/lib/python3.5/site-packages/setuptools-22.0.5-py3.5.egg/pkg_resources/", line 542, in load_entry_point
  File "/usr/lib/python3.5/site-packages/setuptools-22.0.5-py3.5.egg/pkg_resources/", line 2569, in load_entry_point
  File "/usr/lib/python3.5/site-packages/setuptools-22.0.5-py3.5.egg/pkg_resources/", line 2229, in load
  File "/usr/lib/python3.5/site-packages/setuptools-22.0.5-py3.5.egg/pkg_resources/", line 2235, in resolve
  File "/opt/ros2/lib/python3.5/site-packages/topics/", line 18, in <module>
    import rclpy
  File "/opt/ros2/lib/python3.5/site-packages/rclpy/", line 18, in <module>
    from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
  File "/opt/ros2/lib/python3.5/site-packages/rclpy/impl/", line 32, in <module>
    rclpy_implementation = importlib.import_module('._rclpy', package='rclpy')
  File "/usr/lib/python3.5/importlib/", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named 'rclpy._rclpy'

I have noticed that are similar errors at Windows platform.

Regards and thanks.

Hi guys!

any updates about this? I’m having the same issue.

Thanks in advance.



@LanderU can you please open an issue on the rclpy repository with all the information regarding your setup and your install ?

Regarding cross-compilation, sorry @abilbaotm for missing this thread. AFAIK we haven’t tried to cross-compile the Python stack. The logic of the python imports has changes quite a bit since beta2 so the situation may be different today. If you happen to be willing to give it another shot and report here with the details of how you defined and linked against your targets’ python libraries that would be helpful.
In the meantime for ARM users we do provide ros2 debs for aarch64 on and nightly aarch64 builds here.

Thanks you both for reporting these issues

Hi @marguedas,

thanks for the reply. I was able to avoid the error. It seems that when we try to cross compile it is not deploying the necessary stuff with the proper names (arm…)



We also discovered that buying ARM processors is cheaper than making the cross-compile work.

1 Like

Sorry for resurrecting this old thread, but several links on the web point 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:


For example

colcon build \
    --cmake-force-configure \
    --cmake-args \
    -DCMAKE_TOOLCHAIN_FILE=`pwd`/rpi3_toolchainfile.cmake \

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/

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

For a full example you can refer to this repository for RaspberryPi cross-compilation.