ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

colcon build errors... Failed <<< rclpy [8.28s, exited with code 2]

asked 2022-06-30 02:16:04 -0500

Jingqiu gravatar image

updated 2022-06-30 02:42:16 -0500

Hi everyone.

I faced a problem that failed colccon build ros2_humble on ubuntu 20.04. I followed the building as this link

But I failed in this step: colcon build --symlink-install.

And got the error below:

--- stderr: rclpy
In file included from /home/zuo2/ros2_humble/src/ros2/rclpy/rclpy/src/rclpy/node.hpp:24, from /home/zuo2/ros2_humble/src/ros2/rclpy/rclpy/src/rclpy/action_client.hpp:26, from /home/zuo2/ros2_humble/src/ros2/rclpy/rclpy/src/rclpy/_rclpy_pybind11.cpp:24: /home/zuo2/ros2_humble/src/ros2/rclpy/rclpy/src/rclpy/context.hpp: In destructor ‘rclpy::InitOptions::~InitOptions()’: /home/zuo2/ros2_humble/src/ros2/rclpy/rclpy/src/rclpy/context.hpp:49:7: error: ‘PyErr_WarnFormat’ was not declared in this scope; did you mean ‘PyErr_Format’?

49 | PyErr_WarnFormat(
| ^~~~~~~~~~~~~~~~
| PyErr_Format

make[2]: * [CMakeFiles/_rclpy_pybind11.dir/build.make:76: CMakeFiles/_rclpy_pybind11.dir/src/rclpy/_rclpy_pybind11.cpp.o] error 1
make[1]: * [CMakeFiles/Makefile2:104:CMakeFiles/_rclpy_pybind11.dir/all] error 2
make: * [Makefile:141:all] error 2
--- Failed <<< rclpy [8.28s, exited with code 2]
Aborted <<< action_tutorials_interfaces [2.03s]
Aborted <<< rclcpp [8.69s]
Aborted <<< rviz_rendering [1min 40s]
Summary: 189 packages finished [2min 31s]
1 package failed: rclpy
3 packages aborted: action_tutorials_interfaces rclcpp rviz_rendering
1 package had stderr output: rclpy
147 packages not processed

What is the cause?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2022-06-30 09:28:13 -0500

ljaniec gravatar image

Can you check your Python version? Most likely you have python-is-python2 installed, and that is throwing the colcon error detection off. Can you see if that is the case, and try uninstalling it?

edit flag offensive delete link more

Comments

I have set the default python to be 3.8.10, while python --version get python 3.8.10. But colcon build still failed for the same error. while I didn't uninstall the python2, because it said Ubuntu is based on Python2, uninstalling may cause to Ubuntu crash. Is this still the problem with python?

Jingqiu gravatar image Jingqiu  ( 2022-06-30 20:56:09 -0500 )edit

You should leave the Python2 for Ubuntu untouched, can you try install python-is-python3 just to be sure? ROS 2 Humble is targeted for Ubuntu 22.04 too, for 20.04 there are Galactic and Foxy

ljaniec gravatar image ljaniec  ( 2022-07-03 18:17:52 -0500 )edit

Hi there i used this method of python-is-python3 but i have the same error of "rclpy" , here i am getting issue with --> "_rclpy_pybind11" directory ... I am using python=3.8.10 & ROS Humble , please help me out

pro_chowdhury gravatar image pro_chowdhury  ( 2022-11-04 02:32:19 -0500 )edit

If you still have Ubuntu 20.04, you have to work more to get ROS2 Humble working (it targets Ubuntu 22.04) - can you try this official Ubuntu tutorial "Install ROS 2 Humble in Ubuntu 20.04 or 18.04 using LXD containers"?

ljaniec gravatar image ljaniec  ( 2022-11-07 14:25:25 -0500 )edit

I am facing the same issue as you are. Did you manage to find a solution for this in the end?

helpless_rosboy gravatar image helpless_rosboy  ( 2023-03-23 04:56:35 -0500 )edit
1

confirm the python to be 3.8,and then:colcon build --packages-select rclpy --symlink-install --cmake-args -DPYTHON_EXECUTABLE=/your/path/to/python

xjjl gravatar image xjjl  ( 2023-05-23 03:19:00 -0500 )edit

I have tried your solution @xjjl, using: colcon build --packages-select rclpy --symlink-install --cmake-args -DPYTHON_EXECUTABLE=/usr/bin/python, but I get the following error message:

--- stderr: rclpy /usr/bin/ld: CMakeFiles/test_python_allocator.dir/test/test_python_allocator.cpp.o: in function _Py_DECREF': test_python_allocator.cpp:(.text+0x5b): undefined reference to _Py_Dealloc'

Reka gravatar image Reka  ( 2023-06-05 09:01:54 -0500 )edit
0

answered 2023-07-09 10:49:57 -0500

crzonga gravatar image

There is a great answer from the Nvidia Jetson ROS 2 docker scene: https://github.com/dusty-nv/jetson-co...

TLDR:

According to your error message, the only step that is relevant to your error should be related to pybind. Thus you can remove pybind11-dev and python -m pip install pybind11-global to have a more updated pybind that Humble actually can use.

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2022-06-30 02:16:04 -0500

Seen: 1,273 times

Last updated: Jul 09 '23