1

When doing colcon build step in RealSense-ROS installation tutorial I face the CMake Error:

AttributeError: module 'em' has no attribute 'BUFFERED_OPT'

In my ros2_ws/src folder I have realsense-ros, vision_opencv, and xacro as the latter 2 caused errors of missing on rosdep install.

The software versions are:

  • OS: Debian 12
  • ROS distribution: Jazzy
  • RealSense SDK: librealsense-2.47.0
  • RealSense ROS wrapper: realsense-ros 3.2.2
  • C compiler: GNU 12.2.0
  • ament_cmake_ros: 0.12.0
  • Python: 3.11.2
  • em library: python3-empy 3.3.4-2

The full error log:

user@device:~/ros2_ws $ colcon build
Starting >>> cv_bridge
Starting >>> realsense2_camera_msgs
Starting >>> image_geometry
Starting >>> xacro
--- stderr: realsense2_camera_msgs
CMake Error at /opt/ros/jazzy/share/rosidl_adapter/cmake/rosidl_adapt_interfaces.cmake:57 (message):
 execute_process(/usr/bin/python3 -m rosidl_adapter --package-name
 realsense2_camera_msgs --arguments-file
 /home/pi/ros2_ws/build/realsense2_camera_msgs/rosidl_adapter__arguments__realsense2_camera_msgs.json
 --output-dir
 /home/pi/ros2_ws/build/realsense2_camera_msgs/rosidl_adapter/realsense2_camera_msgs
 --output-file
 /home/pi/ros2_ws/build/realsense2_camera_msgs/rosidl_adapter/realsense2_camera_msgs.idls)
 returned error code 1:
 AttributeError processing template 'msg.idl.em'
 Traceback (most recent call last):
 File "/opt/ros/jazzy/lib/python3.11/site-packages/rosidl_adapter/resource/__init__.py", line 51, in evaluate_template
 em.BUFFERED_OPT: True,
 ^^^^^^^^^^^^^^^
 AttributeError: module 'em' has no attribute 'BUFFERED_OPT'
 During handling of the above exception, another exception occurred:
 Traceback (most recent call last):
 File "<frozen runpy>", line 198, in _run_module_as_main
 File "<frozen runpy>", line 88, in _run_code
 File "/opt/ros/jazzy/lib/python3.11/site-packages/rosidl_adapter/__main__.py", line 19, in <module>
 sys.exit(main())
 ^^^^^^
 File "/opt/ros/jazzy/lib/python3.11/site-packages/rosidl_adapter/main.py", line 53, in main
 abs_idl_file = convert_to_idl(
 ^^^^^^^^^^^^^^^
 File "/opt/ros/jazzy/lib/python3.11/site-packages/rosidl_adapter/__init__.py", line 19, in convert_to_idl
 return convert_msg_to_idl(
 ^^^^^^^^^^^^^^^^^^^
 File "/opt/ros/jazzy/lib/python3.11/site-packages/rosidl_adapter/msg/__init__.py", line 39, in convert_msg_to_idl
 expand_template('msg.idl.em', data, output_file, encoding='iso-8859-1')
 File "/opt/ros/jazzy/lib/python3.11/site-packages/rosidl_adapter/resource/__init__.py", line 23, in expand_template
 content = evaluate_template(template_name, data)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/opt/ros/jazzy/lib/python3.11/site-packages/rosidl_adapter/resource/__init__.py", line 69, in evaluate_template
 _interpreter.shutdown()
 ^^^^^^^^^^^^^^^^^^^^^
 AttributeError: 'NoneType' object has no attribute 'shutdown'
Call Stack (most recent call first):
 /opt/ros/jazzy/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:132 (rosidl_adapt_interfaces)
 CMakeLists.txt:22 (rosidl_generate_interfaces)
---
Failed <<< realsense2_camera_msgs [4.00s, exited with code 1]
Aborted <<< xacro [9.19s]
Aborted <<< image_geometry [1min 3s]
Aborted <<< cv_bridge [1min 51s]
Summary: 0 packages finished [1min 52s]
 1 package failed: realsense2_camera_msgs
 3 packages aborted: cv_bridge image_geometry xacro
 2 packages had stderr output: realsense2_camera_msgs xacro
 4 packages not processed

I tried:

  • to update all versions and clean error logs, as descibed here
  • to uninstall em and install empy instead, as described here, but with apt install python3-*

Nothing worked for me though. Thanks for any help in advance!

asked Oct 23, 2024 at 12:36
2
  • Here is the log for command colcon build --symlink-install --event-handlers console_cohesion+ --continue-on-error Commented Oct 23, 2024 at 13:03
  • Okay, it turned out that ROS2 didn't work properly, so the earlier steps of the tutorial may be the root of evil. But if there are any ideas other than that, I would appreciate them. Commented Oct 25, 2024 at 8:01

1 Answer 1

3

I faced the same issue, while trying colcon build, the source of the error is the incorrect version of empy, I fixed it by installing empy version 3.3.4 (pip install empy==3.3.4) for humble distro.

Hope this helps....

also, the conda environment can interfere with this, make sure to cross verify the conda environment using (which python3).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.