O'Reilly logo

Programming Python, Second Edition by Mark Lutz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Environment Configuration

This section introduces Python environment setup details and describes settings that impact Python programs.

Shell Variables

The following shell environment variables (among others) are usually important when using Python:

PYTHONPATH

Python’s module file search path. If set, it is used to locate modules at run- time when they’re imported by a Python program -- Python looks for an imported module file or package directory in each directory listed on PYTHONPATH, from left to right. Python generally searches the home directory of a script as well as the Python standard source code library directory automatically, so you don’t need to add these. Hint: check sys.path interactively to see how the path is truly set up.

PYTHONSTARTUP

An optional Python initialization file. If used, set this variable to the full path-name of a file of Python code (a module) that you want to be run each time the Python interactive command-line interpreter starts up. This is a convenient way to import modules you use frequently when working interactively.

PATH

The operating system’s executable search path variable. It is used to locate program files when you type their names at a command line without their full directory paths. Add the directory containing the python interpreter executable file (or else you must retype its directory path each time).

In addition, users on platforms other than Windows may need to set variables to use Tkinter if Tcl/Tk installations cannot be ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required