colcon build failures windows- beginner

asked 2023-01-29 05:50:51 -0600

DrBwts gravatar image

updated 2023-01-29 05:51:18 -0600

I'm going thorugh the beginners tutorials but I've run into problem building packages with colcon. I searched for similar questions but no joy.

I'm running as admin from a VS 2019 command line, I sourced ros2 by running the local_setup.bat file

Win10 x64, ROS 2 - Humble, VS 2019

 --- stderr: examples_rclcpp_minimal_publisher
Traceback (most recent call last):
  File "C:\ROS_Humble\ros2\share\ament_cmake_core\cmake\core\", line 22, in <module>
    from catkin_pkg.package import parse_package_string
ModuleNotFoundError: No module named 'catkin_pkg'
CMake Error at C:/ROS_Humble/ros2/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:95 (message):
  returned error code 1
Call Stack (most recent call first):
  C:/ROS_Humble/ros2/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:49 (_ament_package_xml)
  C:/ROS_Humble/ros2/share/ament_lint_auto/cmake/ament_lint_auto_find_test_dependencies.cmake:31 (ament_package_xml)
  CMakeLists.txt:47 (ament_lint_auto_find_test_dependencies)
edit retag flag offensive close merge delete



you appear to have Anaconda installed, which is an alternative Python interpreter.

The ROS 2 for Windows distributions will not work with it, as the required Python dependencies (such as catkin_pkg) are only installed for the Python interpreter ROS 2 was build for/with.

gvdhoorn gravatar image gvdhoorn  ( 2023-01-31 04:38:41 -0600 )edit

So I have to uninstall Anaconda to use ROS2? That seems kinda drastic

DrBwts gravatar image DrBwts  ( 2023-01-31 07:57:46 -0600 )edit

No. You need to make sure the terminal/cmd window you run Colcon in has it's PATH updated such that it can't find (or "see") Anaconda. That is all.

gvdhoorn gravatar image gvdhoorn  ( 2023-01-31 08:00:06 -0600 )edit

Ahh OK, how do I do that?

DrBwts gravatar image DrBwts  ( 2023-01-31 08:17:53 -0600 )edit

Provided you've not built ROS 2 from source using Anaconda (in that case I would not expect the issue you report), you could use a procedure like this one (NOTE: just a random link to a page describing how to edit the PATH under Windows 10). All cmd windows started after making the change(s) would have the updated PATH.

You probably don't even need to remove Anaconda from the PATH. Making the entry for Anaconda in PATH point to an invalid path should already work.

gvdhoorn gravatar image gvdhoorn  ( 2023-01-31 09:32:16 -0600 )edit

Do I add a new path entry to point colcon to ROS's own version of Python or is it just enough to stop it pointing at Conda?

DrBwts gravatar image DrBwts  ( 2023-01-31 11:43:39 -0600 )edit