Tutorial: Setting Python Path

Index of All Documentation » Wing Tutorial »

Whenever your Python source depends on PYTHONPATH, either set externally or by altering sys.path at runtime, you will also need to tell Wing about your path.

This value can be entered in Python Path in the Project Properties dialog, which is accessible from the Project menu and the toolbar:


For this tutorial, you need to add the subdir sub-directory of your tutorials directory to Python Path, as shown above. This directory contains a module used as part of the first coding example.

Note that the full path to the directory subdir is used. This is strongly recommended because it avoids potential problems finding source code when the starting directory is ambiguous or changes over time. If relative paths are needed to make a project work on different machines, use an environment variable like ${WING:PROJECT_DIR}/subdir. This is described in more detail in Environment Variable Expansion.

The configuration used here is for illustrative purposes only. You could run the example code without altering PYTHONPATH by moving the path_example.py file to the same location as the example scripts, or by placing it into your Python installation's site-packages directory, which is in the default PYTHONPATH.

Python Path Hints

If your main entry point is Python code that alters sys.path, and the file is set as the Main Entry Point in Project Properties then Wing can often determine the correct PYTHONPATH to use without any changes to Python Path in Project Properties.

When in doubt, compare value of sys.path at runtime in your code with the value reported by Show Python Environment in the Source menu.