Colcon build: ModuleNotFoundError: No module named 'ament_package'

asked 2021-09-08 20:00:44 -0500

jamesross2 gravatar image

updated 2021-09-09 06:26:09 -0500

gvdhoorn gravatar image

Any help would be appreciated. Thank you.

(base) birth@birth-Inspiron-7570:~/workspace/ros_ws_foxy_ur_driver$ sudo colcon build
Starting >>> control_msgs
Starting >>> ros2_control_test_assets
Starting >>> controller_manager_msgs
Starting >>> diffbot_description
Starting >>> ros2_control_test_nodes
Starting >>> rrbot_description
Starting >>> ur_client_library
Starting >>> ur_dashboard_msgs
--- stderr: control_msgs                                          
Traceback (most recent call last):
  File "/opt/ros/foxy/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py", 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/foxy/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message):
  execute_process(/home/birth/anaconda3/bin/python3
  /opt/ros/foxy/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py
  /home/birth/workspace/ros_ws_foxy_ur_driver/build/control_msgs/ament_cmake_package_templates/templates.cmake)
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/foxy/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:41 (include)
  /opt/ros/foxy/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package)
  /opt/ros/foxy/share/ament_cmake/cmake/ament_cmakeConfig.cmake:41 (include)
  CMakeLists.txt:13 (find_package)


---
Failed   <<< control_msgs [0.42s, exited with code 1]
--- stderr: ros2_control_test_assets
Traceback (most recent call last):
  File "/opt/ros/foxy/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py", 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/foxy/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message):
  execute_process(/home/birth/anaconda3/bin/python3
  /opt/ros/foxy/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py
  /home/birth/workspace/ros_ws_foxy_ur_driver/build/ros2_control_test_assets/ament_cmake_package_templates/templates.cmake)
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/foxy/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:41 (include)
  /opt/ros/foxy/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package)
  /opt/ros/foxy/share/ament_cmake/cmake/ament_cmakeConfig.cmake:41 (include)
  CMakeLists.txt:5 (find_package)


---
Failed   <<< ros2_control_test_assets [0.41s, exited with code 1]
--- stderr: controller_manager_msgs              
Traceback (most recent call last):
  File "/opt/ros/foxy/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py", 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/foxy/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message):
  execute_process(/home/birth/anaconda3/bin/python3
  /opt/ros/foxy/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py
  /home/birth/workspace/ros_ws_foxy_ur_driver/build/controller_manager_msgs/ament_cmake_package_templates/templates.cmake)
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/foxy/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:41 (include)
  /opt/ros/foxy/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package)
  /opt/ros/foxy/share/ament_cmake/cmake/ament_cmakeConfig.cmake:41 (include)
  CMakeLists.txt:8 (find_package)
edit retag flag offensive close merge delete

Comments

execute_process(/home/birth/anaconda3/bin/python3

seems to be another case of Anaconda getting in the way.

See Should we warn (new) users about difficulties with Python 3 and alternative Python interpreters? for a related discussion.

This is not a Colcon problem (nor Ament).

gvdhoorn gravatar image gvdhoorn  ( 2021-09-09 06:25:36 -0500 )edit

Related. If you'd like more help please explain how you have setup your workspace with enough information to reproduce the problem for us to be able to help you more than guessing that there's a conflict with Anaconda.

tfoote gravatar image tfoote  ( 2021-09-10 05:13:08 -0500 )edit