ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ModuleNotFoundError: No module named 'ament_package'

asked 2022-06-07 12:37:47 -0500

Ellie gravatar image

updated 2023-07-08 14:11:06 -0500

Andromeda gravatar image


I am getting the following error when I am trying colcon build, I tried almost all suggested solutions and none of them working for me. can you please help me? I source my environment. I tried both ros2 foxy and ros2 galactic, same error.

sudo colcon build --install-base=/opt/performance_test --merge-install --cmake-clean-cache --cmake-args -DCMAKE_PREFIX_PATH=/opt/ros/ Starting >>> performance_test --- stderr: performance_test Traceback (most recent call last):
File "/opt/ros/ament_cmake_core/share/ament_cmake_core/cmake/package_templates/", line 21, in <module> from ament_package.templates import get_environment_hook_template_path ModuleNotFoundError: No module named 'ament_package' CMake Error at /opt/ros/ament_cmake_core/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message):
/opt/ros/ament_cmake_core/share/ament_cmake_core/cmake/package_templates/ /home/ubuntu/perf_test_ws/build/performance_test/ament_cmake_package_templates/templates.cmake) returned error code 1 Call Stack (most recent call first):
/opt/ros/ament_cmake_core/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:41 (include)
/opt/ros/ament_cmake/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package)
/opt/ros/ament_cmake/share/ament_cmake/cmake/ament_cmakeConfig.cmake:41 (include) CMakeLists.txt:27 (find_package)

Thank you

edit retag flag offensive close merge delete


I have exactly the same issue, and I am still stuck

Fahima Mokhtari gravatar image Fahima Mokhtari  ( 2022-10-18 05:23:57 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2023-07-08 14:11:40 -0500

Andromeda gravatar image

Run colcon without sudo:

$colcon build ...

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2022-06-07 12:37:47 -0500

Seen: 227 times

Last updated: Jul 08 '23