Most operating systems provide the means to set environment variables temporarily, by configuring them during a particular session, or permanently, by configuring them as part of the operating system setup. Precisely how you perform this task depends on the operating system. For example, when working with Windows, you can use the Set
command (see the blog post at for details) or rely on a special Windows configuration feature (see this blog post for setting the Path
environment variable as an example).
Using environment variables makes sense when you need to configure Python the same way on a regular basis. The following list describes the Python environment variables:
PYTHONCASEOK=
x: Forces Python to ignore case when parsingimport
statements. This is a Windows-only environment variable.PYTHONDEBUG=
x: Performs the same task as the-d
option.PYTHONDONTWRITEBYTECODE=
x: Performs the same task as the-B
option.PYTHONFAULTHANDLER=
x: Forces Python to dump the Python traceback (list of calls that led to an error) on fatal errors.PYTHONHASHSEED=<em>arg</em>
: Determines the seed value used to generate hash values from various kinds of data. When this variable is set torandom
, Python uses a random value to seed the hashes ofstr
,bytes
, anddatetime
objects. The valid integer range is 0 to 4294967295. Use a specific seed value to obtain predictable hash values for testing purposes.PYTHONHOME=
arg: Defines the default search path that Python uses to look for modules.PYTHONINSPECT=
x: Performs the same task as the-i
option.PYTHONIOENCODING=<em>arg</em>
: Specifies theencoding[:errors]
(such asutf-8
) used for thestdin
,stdout
, andstderr
devices.PYTHONNOUSERSITE
: Performs the same task as the-s
option.PYTHONOPTIMIZE=
x: Performs the same task as the-O
option.PYTHONPATH=<em>arg</em>
: Provides a semicolon (;) separated list of directories to search for modules. This value is stored in thesys.path
variable in Python.PYTHONSTARTUP=<em>arg</em>
: Defines the name of a file to execute when Python starts. There is no default value for this environment variable.PYTHONUNBUFFERED=
x: Performs the same task as the-u
option.PYTHONVERBOSE=
x: Performs the same task as the-v
option.PYTHONWARNINGS=<em>arg</em>
: Performs the same task as the-W
option.