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

importerror catkin_pkg

asked 2018-07-06 18:16:03 -0600

achille gravatar image

updated 2018-07-06 21:33:05 -0600


I reinstalled ROS1 Kinetic on Ubuntu 16.04 since I realized I had been using pip, apt, and virtualenvs in the wrong way.

In my system environment, I installed ROS Kinetic following the guidelines which worked fine. However when I run

sudo rosdep init

I get:

Traceback (most recent call last):
  File "/usr/bin/rosdep", line 3, in <module>
    from rosdep2.main import rosdep_main
  File "/usr/lib/python2.7/dist-packages/rosdep2/", line 45, in <module>
    from .lookup import RosdepDefinition, RosdepView, RosdepLookup, \
  File "/usr/lib/python2.7/dist-packages/rosdep2/", line 41, in <module>
    from .rospkg_loader import RosPkgLoader
  File "/usr/lib/python2.7/dist-packages/rosdep2/", line 37, in <module>
    import catkin_pkg.package
ImportError: No module named catkin_pkg.package

I had solved this before by installing it with pip instead of with apt but this apparently isn't the recommended method. I've also encountered other similar import errors before where python doesn't recognize packages installed with apt.


dpkg -L python-catkin-pkg yields:


dpkg -L ros-kinetic-catkin yields:

/opt/ros ...
edit retag flag offensive close merge delete


What version of the modules do you have installed? dpkg -L python-catkin-pkg-modules

Dirk Thomas gravatar image Dirk Thomas  ( 2018-07-06 18:45:28 -0600 )edit

Updated the question with that output: 0.4.6

achille gravatar image achille  ( 2018-07-06 18:51:38 -0600 )edit

And where is the catkin_pkg module being found? python -c "import catkin_pkg; print(catkin_pkg.__file__)"

Dirk Thomas gravatar image Dirk Thomas  ( 2018-07-06 18:59:50 -0600 )edit

That command is the one that's not working: ImportError: No module named catkin_pkg. I tried all instructions in related questions.

achille gravatar image achille  ( 2018-07-06 21:24:19 -0600 )edit

Can you share the search path: python -c "import sys; print(sys.path)"

Dirk Thomas gravatar image Dirk Thomas  ( 2018-07-06 21:30:32 -0600 )edit

updated the question

achille gravatar image achille  ( 2018-07-06 21:35:23 -0600 )edit

Please try to unset the PYTHONPATH by invoking unset PYTHONPATH. Then try python -c "import catkin_pkg; print(catkin_pkg.__file__)" and python -c "import sys; print(sys.path)" again.

Dirk Thomas gravatar image Dirk Thomas  ( 2018-07-06 22:13:28 -0600 )edit

The import still fails, even after restarting the terminal. sys.path does contain /usr/lib/python2.7/dist-packages now though.

achille gravatar image achille  ( 2018-07-06 22:23:27 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-07-11 10:16:57 -0600

sloretz gravatar image

I don't know the cause, but happy to hear the problem went away after running sudo apt install --reinstall python-catkin-pkg-modules.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-07-06 18:16:03 -0600

Seen: 2,057 times

Last updated: Jul 11 '18