Ask Your Question

rosrun and finding python files in other packages using catkin

asked 2013-03-04 09:57:53 -0500

TommyP gravatar image

updated 2014-01-28 17:15:30 -0500

ngrennan gravatar image

I asked a similar question and got it to work with global scripts but not with rosrun.

So now I wonder how to do the following:

In package A i have


In package B I have a file


which has the line:

from mp import *

Now when I do "rosrun A" is not found. What is the correct way to solve this. Exactly what should I write in and in CMakeFile.txt?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-03-04 10:27:15 -0500

KruseT gravatar image

In of package A, you need to export the module. The cleanest way is to use a python package. So you should put in a python package, like


Then in declare the package mp, and enable the line catkin_python_setup() in A's CMakeLists.txt. Then run catkin_make. This will generate package relay files, in devel/lib/python2.7/dist-packages/A. Then source devel/ This will change your PYTHONPATH to include the package relay files.


edit flag offensive delete link more


OK. So the thing that was possible with rosbuild is no longer possible. That should be documented somewhere since I have wasted some time trying to figure out how to get it to work as with rosbuild. I need to read up on Python packages I see.

TommyP gravatar image TommyP  ( 2013-03-04 10:45:53 -0500 )edit

Got it to work. Thanks for the good answer.

TommyP gravatar image TommyP  ( 2013-03-04 11:05:58 -0500 )edit

Is the package fund before system packages? I have a package called tst but the import seems to select "/usr/share/doc/python-libxml2/examples/". I solved my problem with "import tst.tst" but it was very confusing.

TommyP gravatar image TommyP  ( 2013-03-04 23:18:17 -0500 )edit

That's how python does it, and that's why it is best to always use packages, and to always import giving the full name with the package.

KruseT gravatar image KruseT  ( 2013-03-05 02:30:17 -0500 )edit

Your Answer

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

Add Answer

Question Tools


Asked: 2013-03-04 09:57:53 -0500

Seen: 201 times

Last updated: Mar 04 '13