Trying to Colcon build ROS2 Rolling (https://docs.ros.org/en/rolling/Installation/Ubuntu-Development-Setup.html), I've faced this error:
colcon build --symlink-install
Starting >>> rclpy
--- stderr: rclpy
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find Python3 (missing: Python3_LIBRARIES Python3_INCLUDE_DIRS
Development) (found version "3.9.10")
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.16/Modules/FindPython/Support.cmake:2214 (find_package_handle_standard_args)
/usr/share/cmake-3.16/Modules/FindPython3.cmake:300 (include)
CMakeLists.txt:40 (find_package)
---
Failed <<< rclpy [5.33s, exited with code 1]
My system Python is 3.8.10, my system Ubuntu 20.04. From the logs, it looks like 3.8 is not being found, while 3.9 is picked instead (3.9 is installed too on my system). The other 300s or so packages of ROS2 Rolling installed without issues.
I believe the error was due to colcon picking up the anaconda python, instead of the default OS python (3.8.10 in my case).
https://docs.ros.org/en/rolling/How-To-Guides/Installation-Troubleshooting.html#import-failing-without-library-present-on-the-system