Note: This tutorial assumes that you have completed the previous tutorials: ROS tutorials.

Setting Up Your PYTHONPATH

Description: Setting up your PYTHONPATH is very easy. You already have to write a manifest.xml file that declares your dependencies, so ROS will use this same manifest file to help you set your PYTHONPATH (we try to use the DRY -- Don't Repeat Yourself -- principle as much as possible).

Tutorial Level: BEGINNER

Contents

This is all you need to do:

  1. Make sure that your dependencies are properly listed in your Manifest

  2. Add the following line to the top of your Python code:

    import roslib; roslib.load_manifest('your_package_name')

NOTE: This line doesn't need to go at the top of every Python file; they just need to go at the top of any file that is a 'main' entry point.

roslib will load up your manifest file and set sys.path to point to the appropriate directory in every package you depend on. These two lines work because roslib is required to be on the PYTHONPATH of every ROS user.


Wiki: rospy_tutorials/Tutorials/PythonPath (last edited 2009-09-11 06:29:09 by MeloneeWise)