ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org
Ask Your Question
0

importerror catkin_pkg

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

achille gravatar image

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

Problem

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/__init__.py", line 45, in <module>
    from .lookup import RosdepDefinition, RosdepView, RosdepLookup, \
  File "/usr/lib/python2.7/dist-packages/rosdep2/lookup.py", line 41, in <module>
    from .rospkg_loader import RosPkgLoader
  File "/usr/lib/python2.7/dist-packages/rosdep2/rospkg_loader.py", 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.

Details

dpkg -L python-catkin-pkg yields:

/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/python-catkin-pkg
/usr/share/doc/python-catkin-pkg/copyright
/usr/share/doc/python-catkin-pkg/changelog.Debian.gz
/usr/lib
/usr/lib/python2.7
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.6.egg-info
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.6.egg-info/top_level.txt
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.6.egg-info/dependency_links.txt
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.6.egg-info/entry_points.txt
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.6.egg-info/PKG-INFO
/usr/lib/python2.7/dist-packages/catkin_pkg-0.4.6.egg-info/requires.txt
/usr/bin
/usr/bin/catkin_find_pkg
/usr/bin/catkin_create_pkg
/usr/bin/catkin_test_changelog
/usr/bin/catkin_prepare_release
/usr/bin/catkin_package_version
/usr/bin/catkin_tag_changelog
/usr/bin/catkin_generate_changelog

dpkg -L ros-kinetic-catkin yields:

/.
/opt
/opt/ros
/opt/ros/kinetic
/opt/ros/kinetic/setup.bash
/opt/ros/kinetic/lib
/opt/ros/kinetic/lib/python2.7
/opt/ros/kinetic/lib/python2.7/dist-packages
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin-0.7.11.egg-info
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/workspace_vcs.py
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/package_version.pyc
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/tidy_xml.py
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/cmake.py
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/tidy_xml.pyc
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/init_workspace.py
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/terminal_color.py
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/test_results.py
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/environment_cache.py
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/workspace.py
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/find_in_workspaces.py
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/find_in_workspaces.pyc
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/package_version.py
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/builder.pyc
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/init_workspace.pyc
/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/__init__.py
/opt/ros ...
(more)
edit retag flag offensive close merge delete

Comments

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

Dirk Thomas gravatar imageDirk Thomas ( 2018-07-06 18:45:28 -0500 )edit

Updated the question with that output: 0.4.6

achille gravatar imageachille ( 2018-07-06 18:51:38 -0500 )edit

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

Dirk Thomas gravatar imageDirk Thomas ( 2018-07-06 18:59:50 -0500 )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 imageachille ( 2018-07-06 21:24:19 -0500 )edit

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

Dirk Thomas gravatar imageDirk Thomas ( 2018-07-06 21:30:32 -0500 )edit

updated the question

achille gravatar imageachille ( 2018-07-06 21:35:23 -0500 )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 imageDirk Thomas ( 2018-07-06 22:13:28 -0500 )edit

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

achille gravatar imageachille ( 2018-07-06 22:23:27 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 388 times

Last updated: Jul 11 '18