ModuleNotFoundError: No module named 'catkin_pkg' problem when building a new package

asked 2021-03-15 16:33:21 -0500

pablo.arandarod gravatar image

I'm trying to do the tutorial from the tutorial. When I'm trying to build the package, I receive the following error code:

--- stderr: my_packate                         
Traceback (most recent call last):
  File "/home/pablo/ros2_foxy/install/ament_cmake_core/share/ament_cmake_core/cmake/core/", line 21, in <module>
    from catkin_pkg.package import parse_package_string
ModuleNotFoundError: No module named 'catkin_pkg'
CMake Error at /home/pablo/ros2_foxy/install/ament_cmake_core/share/ament_cmake_core/cmake

/core/ament_package_xml.cmake:94 (message):
  returned error code 1
Call Stack (most recent call first):
  /home/pablo/ros2_foxy/install/ament_cmake_core/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:49 (_ament_package_xml)
  /home/pablo/ros2_foxy/install/ament_lint_auto/share/ament_lint_auto/cmake/ament_lint_auto_find_test_dependencies.cmake:31 (ament_package_xml)
  CMakeLists.txt:30 (ament_lint_auto_find_test_dependencies)

I've done some modifications to the CMakeList.text file, such as uncommenting the line that said set(ament_cmake_cpplint_FOUND TRUE), but it didn't solve the problem.

I tried what I saw of installing the python3-catking-pkg, but it is already installed.

edit retag flag offensive close merge delete


Just try this line in place of python3:

sudo apt-get install python-catkin-pkg

Reason: This allows to install python-catkin-pkg-modules and python3-catkin-pkg-modules at the same time.

Ranjit gravatar image Ranjit  ( 2021-03-16 07:44:15 -0500 )edit

@Ranjit I tried, but it didn't work.

In any way, I downloaded the file from the tutorial and it seemed to work.

pablo.arandarod gravatar image pablo.arandarod  ( 2021-03-16 17:15:30 -0500 )edit