Robotics StackExchange | Archived questions

ROS2 Foxy: rclpy: failure when importing rclpy.node

My Environment: ubuntu20.04 + ROS2 Foxy + AARCH64

I'm new to ROS2 and I'm practicing python client example (https://docs.ros.org/en/foxy/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.html), and found there is a problem when importing rclpy.node, however importing rclpy only works.

I followed the installation guide (https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Debians.html) and installed foxy successfully, demonodespy talker/listener can run correctly, ros2 topics/node/topics command can also work. The only issue is the python program fails when "from rclpy.node import Node", please help me, thanks.

My environment is in the bottom of the description:

(base) test@ubuntu20.04:~$ python3
Python 3.10.8 (main, Nov 24 2022, 14:06:33) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rclpy
>>> from rclpy.node import Node
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/node.py", line 42, in <module>
from rclpy.client import Client
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/client.py", line 22, in <module>
from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/impl/implementation_singleton.py", line 31, in <module>
rclpy_implementation = _import('._rclpy')
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/impl/init.py", line 28, in _import
return importlib.import_module(name, package='rclpy')
File "/home/yingliu/miniconda3/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'rclpy._rclpy'
The C extension '/opt/ros/foxy/lib/python3.8/site-packages/rclpy/_rclpy.cpython-310-aarch64-linux-gnu.so' isn't present on the system. Please refer to 'https://index.ros.org/doc/ros2/Troubleshooting/Installation-Troubleshooting/#import-failing-without-library-present-on-the-system' for possible solutions
>>>
(base) test@ubuntu20.04:~$ printenv |grep -i ros
ROS_VERSION=2
ROS_PYTHON_VERSION=3
AMENT_PREFIX_PATH=/opt/ros/foxy
PYTHONPATH=/opt/ros/foxy/lib/python3.8/site-packages
LD_LIBRARY_PATH=/opt/ros/foxy/opt/yaml_cpp_vendor/lib:/opt/ros/foxy/opt/rviz_ogre_vendor/lib:/opt/ros/foxy/lib/aarch64-linux-gnu:/opt/ros/foxy/lib
ROS_LOCALHOST_ONLY=0
PATH=/opt/ros/foxy/bin:/home/test/miniconda3/bin:/home/test/miniconda3/condabin:/home/test/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
ROS_DISTRO=foxy
OLDPWD=/home/test/ros/ros2_ws/src/my_py_pkg/my_py_pkg

Asked by Hector.Liu on 2022-12-25 09:31:24 UTC

Comments

Answers