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

Problem with catkin_make

asked 2013-03-03 04:47:28 -0500

phbou72 gravatar image

updated 2013-03-03 06:22:11 -0500

joq gravatar image

One of my teamates can't compile our school project. The catkin_make command give this error :

ImportError: "from catkin_pkg.topological_order import topological_order" failed: No module named catkin_pkg.packages
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.

We compared our PYTHONPATH and we have the same :

/opt/ros/groovy/lib/python2.7/dist-packages

We tried to reinstall ROS completely, but it doesn't work even after that.

Any suggestion to fix this?

edit retag flag offensive close merge delete

Comments

Did you do sudo apt-get install python-catkin-pkg? It should tell you that it's already installed.

dornhege gravatar image dornhege  ( 2013-03-03 05:28:02 -0500 )edit

Yes we dit.

phbou72 gravatar image phbou72  ( 2013-03-03 05:34:16 -0500 )edit

And if so, make sure there is no old version of catkin_pkg in /usr/local/lib/python2.7/dist-packages

KruseT gravatar image KruseT  ( 2013-03-03 05:35:08 -0500 )edit

What should we do? Delete catkin_pkg in /usr/local/lib/python2.7/dist-packages?

phbou72 gravatar image phbou72  ( 2013-03-03 05:38:11 -0500 )edit

Yes, delete any catkin stuff in /usr/local.

joq gravatar image joq  ( 2013-03-03 05:51:45 -0500 )edit

There's nothing : (. His ubuntu install is almost pristine too...

phbou72 gravatar image phbou72  ( 2013-03-03 06:14:53 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
9

answered 2013-03-03 21:24:42 -0500

KruseT gravatar image

updated 2013-10-24 04:10:03 -0500

  1. sudo apt-get install python-catkin-pkg
  2. sudo rm -rf /usr/local/lib/python2.7/dist-packages/catkin*
  3. sudo dpkg -L python-catkin-pkg

    This shows you where apt installed catkin_pkg to, this one should be found.

  4. python -c 'import catkin_pkg; print(catkin_pkg.__file__)'

    This shows you where it actually finds catkin_pkg, if it is different from the above, delete the folder

  5. python -c 'import sys; print(sys.path)'

    This shows you all places where it looks for catkin_pkg

UPDATE:

python2.7 finds the installed code at /usr/lib/pymodules/python2.7, As explained by @joq. if you do not see catkin_pkg folder in there, you need to

sudo apt-get install --reinstall python-catkin-pkg
edit flag offensive delete link more

Comments

Using the above, I found that my catkin_pkg is installed in '/usr/share/pyshared/catkin_pkg', so I added this to my .bashrc file: export PYTHONPATH=/usr/share/pyshared:${PYTHONPATH}

oferbtl gravatar image oferbtl  ( 2013-10-08 01:10:13 -0500 )edit
2

The package installs there, but it is not where PYTHONPATH should point. Post-install should have created compiled modules for each python version you have installed, e.g. /usr/lib/pymodules/python2.7/catkin_pkg/*. Those should be in your python path automatically.

joq gravatar image joq  ( 2013-10-08 06:19:37 -0500 )edit

Could reproduce on some machine with electirc and fuerte installed. When running sudo aptitude reinstall python-catkin-pkg, the relay code appeared.

KruseT gravatar image KruseT  ( 2013-10-24 04:06:11 -0500 )edit
1

@joq, I tried the: "sudo apt-get install --reinstall python-catkin-pkg" and it did install the catkin_pkg in /usr/lib/pymodules/python2.7. However, I checked afterward and did not find that folder in the python search path (python also failed to import the catkin_pkg). I manually appended the path to the PYTHONPATH and python succeeded to find the catkin_pkg. However, I hesitate to change the PYTHONPATH and was hoping that the post install adds it to the search path, but it doesn't seem so. Is it supposed to? what could be wrong? I would appreciate your help. Thanks.

Mo gravatar image Mo  ( 2013-12-18 06:51:34 -0500 )edit

That should be in your PYTHONPATH. Did you source /opt/ros/groovy/setup.bash correctly? What does `echo $PYTHONPATH` show?

joq gravatar image joq  ( 2013-12-18 08:29:42 -0500 )edit

catkin_pkg is a system package - not a catkin package. It is not necessary to source any setup file nor does the PYTHONPATH need to be set.

Dirk Thomas gravatar image Dirk Thomas  ( 2013-12-18 08:33:18 -0500 )edit

@Mo please consider posting the output of the commands (especially 3, 4 and 5) @KruseT has mentioned in his answer for further help.

Dirk Thomas gravatar image Dirk Thomas  ( 2013-12-18 08:34:58 -0500 )edit

Thanks for the reply. I source the setup.bash since afterward I want to catkin a workspace. Below are the variables and python search path. Please note this is running on a test server (travis). *** Sourcing ROS setup: /opt/ros/hydro ROS_PACKAGE_PATH: /opt/ros/hydro/share:/opt/ros/hydro/stacks ***PYTHONPATH: /opt/ros/hydro/lib/python2.7/dist-packages ***Python search path (sys.path): ['', '/opt/ros/hydro/lib/python2.7/dist-packages', '/home/travis/virtualenv/python2.7/lib/python2.7', '/home/travis/virtualenv/python2.7/lib/python2.7/plat-linux2', '/home/travis/virtualenv/python2.7/lib/python2.7/lib-tk', '/home/travis/virtualenv/python2.7/lib/python2.7/lib-old', '/home/travis/virtualenv/python2.7/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages', '/home/travis/virtualenv/python2.7/lib/python2.7/site-packages']

Mo gravatar image Mo  ( 2013-12-18 08:39:11 -0500 )edit
0

answered 2016-11-28 05:32:43 -0500

Prajankya gravatar image

I had the same problem, I had installed ros on python 2 and then sometime afterwards shifted to python 3

Simply I changed the symlink of python from python3 back to python2

edit flag offensive delete link more
0

answered 2018-09-26 00:15:28 -0500

Chad Rockey gravatar image

As mentioned in this related answer https://answers.ros.org/question/2502...

Also check PYTHON_EXECUTABLE. I had a 3rd party program put a line in my bashrc that sourced a different PYTHON_EXECUTABLE. It resulted in an error message about catkin_pkg that brought me to this answer.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-03 04:47:28 -0500

Seen: 33,219 times

Last updated: Sep 26 '18