SPDKalyan
SPDKalyan

Reputation: 21

Ros2 Colcon build failed ,rclpy -error: 'PyErr_warnformat' was not decleared in the scope

Trying to install Ros2 humble in ubuntu 20.04, while executing command --> Colcon build --symlink-install I'm getting the following error

--- stderr: rclpy 
In file included from /home/kalyan/ros2_humble/src/ros2/rclpy/rclpy/src/rclpy/node.hpp:24,
                 from /home/kalyan/ros2_humble/src/ros2/rclpy/rclpy/src/rclpy/action_client.hpp:26,
                 from /home/kalyan/ros2_humble/src/ros2/rclpy/rclpy/src/rclpy/_rclpy_pybind11.cpp:24:
/home/kalyan/ros2_humble/src/ros2/rclpy/rclpy/src/rclpy/context.hpp: In destructor ‘rclpy::InitOptions::~InitOptions()’:
/home/kalyan/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 [16.2s, exited with code 2]
Aborted  <<< rclcpp [26.0s]                                                                                                                                      
Aborted  <<< ros2cli_test_interfaces [1min 29s]                                                                                                  
Aborted  <<< diagnostic_msgs [1min 32s]                                             

Summary: 195 packages finished [4min 31s]
  1 package failed: rclpy
  3 packages aborted: diagnostic_msgs rclcpp ros2cli_test_interfaces
  1 package had stderr output: rclpy
  141 packages not processed

Help me to overcome this error. pyhton3 version-->3.8.10 I have the python3.9 version too,

Upvotes: 1

Views: 2000

Answers (3)

Ahmet Kıpkıp
Ahmet Kıpkıp

Reputation: 1

added "include_directories(/usr/lib/python3.8)" to if(BUILD_TESTING) method in cmakelists to fix it.

Upvotes: 0

Kevin Finisterre
Kevin Finisterre

Reputation: 31

This fixed it for me:

$ sudo apt-get install python-is-python3

Upvotes: 2

suwei
suwei

Reputation: 1

if python version < 3.2, it dose not have PyErr_WarnFormat().seehttps://docs.python.org/3/c-api/exceptions.html. I delete /usr/include/python2.7/ and make the default python version is 3.8.10. It work for me.

Upvotes: 0

Related Questions