ROS2 - ModuleNotFoundError: No module named 'rclpy._rclpy'

Hi,

I run a ROS2 Node which publishes positions (X,Y,Z). In IsaacSIM I want to subscribe to this topic and move the DigitalTwin to the published positions .

Unfortunately I cant create any ROS2 node or subscribe to any topic in IsaacSIM.
when importing Subscriptions:

from rclpy.subscription import Subscription

I geht the following error message:

Traceback (most recent call last):
  File "/home/isy/workspace/src/ISY-Project_UR5e/ur_isaacsim/ur_isaacsim.py", line 20, in <module>
    from rclpy.subscription import Subscription
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/subscription.py", line 19, in <module>
    from rclpy.handle import Handle
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/handle.py", line 17, in <module>
    from rclpy.impl.implementation_singleton import rclpy_handle_implementation as _rclpy_handle
  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/isy/.local/share/ov/pkg/isaac_sim-2022.1.1/kit/python/lib/python3.7/importlib/__init__.py", line 127, 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-37m-x86_64-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

How can I get rid of this error message?
Many thanks in advance!

Specifications:
Ubuntu 20.04
ROS2 Foxy
IsaacSIM 2022.1.1

Script is running via:

source /opt/ros/foxy/setup.zsh
cd ~/.local/share/ov/pkg/isaac_sim-2022.1.1/
declare -x LD_LIBRARY_PATH="/exts/omni.isaac.ros2_bridge/bin/"
 ./python.sh ~/workspace/src/ISY-Project_UR5e/ur_isaacsim/ur_isaacsim.py"

Meanwhile I found my error.

Every time I opened a terminal I sourced ROS2 Foxy and the ros2_workspace by default via the .zshrc (.bashrc).
This led to the unwanted behavior.

When opening a terminal to launch the IsaacSIM script I now source:

source ~/.local/share/ov/pkg/isaac_sim-2022.1.1/ros2_workspace/install/local_setup.zsh

And when I open the second terminal to run the ROS2 Nodes I source:

source /opt/ros/foxy/setup.zsh
source ~/workspace/install/setup.zsh 

Now everything works as intended

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.