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
emand installempyinstead, as described here, but withapt install python3-*
Nothing worked for me though. Thanks for any help in advance!
1 Answer 1
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).
colcon build --symlink-install --event-handlers console_cohesion+ --continue-on-error