ModuleNotFoundError: No module named 'pkg_resources'

asked 2020-02-19 22:59:04 -0500

Hi

I am trying to run the tutorial to create a simple publisher and subscriber as mentioned here link

when I do

colcon build --packages-select cpp_pubsub

I get the following

Starting >>> cpp_pubsub
--- stderr: cpp_pubsub                         
Traceback (most recent call last):
  File "/opt/ros/eloquent/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
  File "/opt/ros/eloquent/lib/python3.6/site-packages/ament_package/templates.py", line 18, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

CMake Error at /opt/ros/eloquent/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message):
  execute_process(/home/ros2/bin/python3
  /opt/ros/eloquent/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py
  /home/ros2/ros2_dev_ws/build/cpp_pubsub/ament_cmake_package_templates/templates.cmake)
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/eloquent/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:38 (include)
  /opt/ros/eloquent/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package)

      /opt/ros/eloquent/share/ament_cmake/cmake/ament_cmakeConfig.cmake:38 (include)
      CMakeLists.txt:19 (find_package)


---
Failed   <<< cpp_pubsub [ Exited with code 1 ]

Summary: 0 packages finished [0.28s]
  1 package failed: cpp_pubsub
  1 package had stderr output: cpp_pubsub

I am using ubuntu 18.04

edit retag flag offensive close merge delete

Comments

Hi,

Can you post your CMakeLists.txt and also take a look at the following links: link1link2

Also, please try to import the package in a terminal with python3 running using import pkg_resources. If it gives an error then try installing the package.

astha736 gravatar image astha736  ( 2020-02-20 11:28:14 -0500 )edit