colcon / colcon-ros

Extension for colcon to support ROS packages
http://colcon.readthedocs.io
Apache License 2.0
13 stars 26 forks source link

ModuleNotFoundError: No module named 'catkin_pkg' #118

Closed jhwangbo closed 3 years ago

jhwangbo commented 3 years ago

I followed the install instruction on Ros2 Eloquent. If call colcon build on my workspace, I get this error

ModuleNotFoundError: No module named 'catkin_pkg'

then I tried the instruction here https://colcon.readthedocs.io/en/released/user/installation.html but it didn't help.

I tried sudo apt install python3-catkin-* but it also doesn't work.

Here is the full error log

Starting >>> raisin_soem
--- stderr: raisin_soem                         
Traceback (most recent call last):
  File "/opt/ros/eloquent/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py", line 21, in <module>
    from catkin_pkg.package import parse_package_string
ModuleNotFoundError: No module named 'catkin_pkg'
CMake Error at /opt/ros/eloquent/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:94 (message):
  execute_process(/home/jemin/.virtualenvs/raisim/bin/python3
  /opt/ros/eloquent/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py
  /home/jemin/ros_workspace/src/raisin/raisin_soem/package.xml
  /home/jemin/ros_workspace/build/raisin_soem/ament_cmake_core/package.cmake)
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/eloquent/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:49 (_ament_package_xml)
  /opt/ros/eloquent/share/ament_lint_auto/cmake/ament_lint_auto_find_test_dependencies.cmake:31 (ament_package_xml)
  CMakeLists.txt:33 (ament_lint_auto_find_test_dependencies)

---
Failed   <<< raisin_soem [0.30s, exited with code 1]

Summary: 0 packages finished [0.42s]
  1 package failed: raisin_soem
  1 package had stderr output: raisin_soem
  1 package not processed
jhwangbo commented 3 years ago

execute_process(/home/jemin/.virtualenvs/raisim/bin/python3 this line is very suspicious. It is calling python in my virtualenv. I might have my virtualenv active when I installed it. But clean install doesn't fix this.

dirk-thomas commented 3 years ago

@jhwangbo Your Python environment seems to be off. You need to make sure that all necessary dependencies are available in the used Python environment. If you follow the official instructions you wouldn't have a virtualenv.

Since this is not a problem within colcon I am going to close this ticket. If you need further help troublehshooting your setup you probably get more eyes and feedback by asking on answers.ros.org (or checking for existing questions and answers on similar topics).

jbrodovsky commented 1 year ago

Hey, so following up on this as I had the same issue. As noted, it looks like you're using a virtual environment, so you need to install catkin_pkg into the environment. I'm using conda and I had to install catkin_pkg, empy, and lark:

conda install -c conda-forge catkin_pkg empy lark

apocosipadrino commented 1 year ago

@jbrodovsky you are a master mind... thanks!