Import Issues

My Python package/module doesn't appear to export

By default, your ROS Package will export your_package/src on the PYTHONPATH. If you wish to export files that aren't in this location, you can add an <export> property to your manifest.xml. See the manifest.xml documentation for more details.

import fails (i.e failure to import submodule)

If you're trying to import a submodule, e.g. (the bar module in foo), there are a couple common errors:

  1. Does your package have <depend package="foo"/> in the manifest.xml file?

  2. Is foo missing an file? In Python, in order to create submodules, you have to have an in a directory to mark it as a module, e.g.


Ctrl-C issues

Error: Node doesn't respond to Ctrl-C

Code written using rospy needs to regularly check for rospy.is_shutdown(), or it should call rospy.spin() from the Main Thread.

For example, this is bad code:

while True:

This is good code:

while not rospy.is_shutdown():

If you don't need to publish anything (e.g. your Node just subscribes or provides a Service), you can instead just call rospy.spin(), which does nothing, except for waiting for an exit signal.

Import errors

Error: No module named roslib

This probably means that your PYTHONPATH is not configured. Please make sure that your PYTHONPATH includes $ROS_ROOT/core/roslib/src.

Error: No module named...

  • Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named foo

The ROS Python client libraries do a lot of the work for you to set your PYTHONPATH, but there are a couple of rules you need to follow to have this magic work correctly:

  1. Does your file include the correct call to:

    import roslib; roslib.load_manifest('your_package_name')
  2. If the package you are attempting to import is a ROS Package, does your manifest.xml include the correct <depend package="foo"/> tag?

  3. If the package you are attempting to import is a non-ROS, system-installed dependency (e.g. wxWidgets), has it been properly installed? One way to test this is to run rosdep install your_package

GUI Issues

GTK: Threads don't work

If you're using rospy with GTK, you will need to use GTK's calls to enable proper Python threading. In particular, multithreaded applications using the Python threading module won't work properly unless you call:


before you call gtk.main().

Wiki: rospy/Troubleshooting (last edited 2009-11-11 05:53:00 by KenConley)