Environment Variables

Environment variables are system-wide settings that span programs and are used for global configuration.

Operational Variables

PYTHONPATH

Augments the default search path for imported module files. The format is the same as the shell’s PATH setting: directory pathnames separated by colons (semicolons on Windows). On module imports, Python searches for the corresponding file or directory in each listed directory, from left to right. Merged into sys.path.

PYTHONSTARTUP

If set to the name of a readable file, the Python commands in that file are executed before the first prompt is displayed in interactive mode.

PYTHONHOME

If set, the value is used as an alternate prefix directory for library modules (or sys.prefix, sys.exec_prefix). The default module search path uses sys.prefix/lib.

PYTHONCASEOK

If set, ignores case in import statements (on Windows).

PYTHONIOENCODING

encodingname[:errorhandler] override used for stdin, stdout, and stderr streams.

Command-Line Option Variables

PYTHONDEBUG

If nonempty, same as -d option.

PYTHONDONTWRITEBYTECODE

If nonempty, same as -B option.

PYTHONINSPECT

If nonempty, same as -i option.

PYTHONNOUSERSITE

If nonempty, same as -s option.

PYTHONOPTIMIZE

If nonempty, same as -O option.

PYTHONUNBUFFERED

If nonempty, same as -u option.

PYTHONVERBOSE

If nonempty, same as -v option.

Get Python Pocket Reference, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.