colcon build errors... Failed <<< rclpy [8.28s, exited with code 2]
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/ros2humble/src/ros2/rclpy/rclpy/src/rclpy/node.hpp:24, from /home/zuo2/ros2humble/src/ros2/rclpy/rclpy/src/rclpy/actionclient.hpp:26, from /home/zuo2/ros2humble/src/ros2/rclpy/rclpy/src/rclpy/rclpypybind11.cpp:24: /home/zuo2/ros2humble/src/ros2/rclpy/rclpy/src/rclpy/context.hpp: In destructor ‘rclpy::InitOptions::~InitOptions()’: /home/zuo2/ros2humble/src/ros2/rclpy/rclpy/src/rclpy/context.hpp:49:7: error: ‘PyErrWarnFormat’ was not declared in this scope; did you mean ‘PyErrFormat’?49 | PyErr_WarnFormat(
| ^~~~~~~~~~~~~~~~
| PyErr_Formatmake[2]: * [CMakeFiles/rclpypybind11.dir/build.make:76: CMakeFiles/rclpypybind11.dir/src/rclpy/rclpypybind11.cpp.o] error 1
make[1]: * [CMakeFiles/Makefile2:104:CMakeFiles/rclpypybind11.dir/all] error 2
make: * [Makefile:141:all] error 2
--- Failed <<< rclpy [8.28s, exited with code 2]
Aborted <<< actiontutorialsinterfaces [2.03s]
Aborted <<< rclcpp [8.69s]
Aborted <<< rvizrendering [1min 40s]
Summary: 189 packages finished [2min 31s]
1 package failed: rclpy
3 packages aborted: actiontutorialsinterfaces rclcpp rvizrendering
1 package had stderr output: rclpy
147 packages not processed
What is the cause?
Asked by Jingqiu on 2022-06-30 02:16:04 UTC
Answers
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?
Asked by ljaniec on 2022-06-30 09:28:13 UTC
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?
Asked by Jingqiu on 2022-06-30 20:56:09 UTC
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
Asked by ljaniec on 2022-07-03 18:17:52 UTC
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
Asked by pro_chowdhury on 2022-11-04 02:32:19 UTC
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"?
Asked by ljaniec on 2022-11-07 15:25:25 UTC
I am facing the same issue as you are. Did you manage to find a solution for this in the end?
Asked by helpless_rosboy on 2023-03-23 04:56:35 UTC
confirm the python to be 3.8,and then:colcon build --packages-select rclpy --symlink-install --cmake-args -DPYTHON_EXECUTABLE=/your/path/to/python
Asked by xjjl on 2023-05-23 03:19:00 UTC
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'
Asked by Reka on 2023-06-05 09:01:54 UTC
There is a great answer from the Nvidia Jetson ROS 2 docker scene: https://github.com/dusty-nv/jetson-containers/issues/160#issuecomment-1429572145
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.
Asked by crzonga on 2023-07-09 10:49:57 UTC
Comments