2

Win10 x64, ROS 2 - Humble, VS 2019

I'm going through the ROS beginners tutorials but I've run into problem building packages with colcon and got as far as the Using colcon to build packages tutorial.

I'm running as admin from a VS 2019 command line, I sourced ros2 by running the local_setup.bat file. I installed the colcon extensions, downloaded the examples & set up the directory structure as outlined in the tutorial.

I then tried to build colcon using colcon build --symlink-install --merge-install

Which after installing a few packages complains & aborts the build with,

--- stderr: examples_rclcpp_minimal_publisher
Traceback (most recent call last):
  File "C:\ROS_Humble\ros2\share\ament_cmake_core\cmake\core\package_xml_2_cmake.py", 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):
  execute_process(C:/ProgramData/Anaconda3/python.exe
  C:/ROS_Humble/ros2/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py
  D:/ROS_scratch/dev/ros2_ws/src/examples/rclcpp/topics/minimal_publisher/package.xml
  D:/ROS_scratch/build/examples_rclcpp_minimal_publisher/ament_cmake_core/package.cmake)
  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)

Anyone know what this is about? I've seen a few posts around about people not sourcing ros2 in the right environment but that isn't the issue here.

3 Answers 3

1

As a potential answer, for me, this issue was due to a second python installation through the Windows store that was not visible in the normal programs and applications list. After using the "newer" "Add or Remove Programs" option from Windows, I was able to find the other python installation, remove it, and was able to build.

0

I would start by trying to obtain the catkin_pkg module and making sure it's installed, based on:

ModuleNotFoundError: No module named 'catkin_pkg'

Apparently this should do the trick: pip install -U catkin_pkg


If that doesn't help then I will update my answer with hints on how to debug this to get more information for us.

2
  • No that doesnt solve the problem when I run that I get told catkin_pkg is already installed
    – DrBwts
    Commented Jan 31, 2023 at 17:35
  • 1
    @DrBwts check permissions, i.e. if you installed it for just a single user, it might not be accessible. A clean reinstall is a guarantee in a lot of situations. Also note that you're using C:/ProgramData/Anaconda3/python.exe python shipped with anaconda and their "custom shells" are a source of a lot of environment problems, especially if you do not open it with their shell. That being said, this is 100% a python issue. I would maybe recommend adding a python tag
    – Milan Š.
    Commented Jan 31, 2023 at 19:40
0

If you are using a local env with anaconda you should try installing the following dependencies:

conda install -c conda-forge catkin_pkg empy lark

Not the answer you're looking for? Browse other questions tagged or ask your own question.