blob: 10cb807c38a02c64bfc0d3bb4d07cc0828496831 [file] [log] [blame]
Benjamin Petersonb9869df2016-03-21 22:31:02 -07001.TH PYTHON "1"
Andrew M. Kuchling3afe4f32004-10-07 12:30:54 +00002
Benjamin Peterson5f28b7b2009-03-26 21:49:58 +00003.\" To view this file while editing, run it through groff:
4.\" groff -Tascii -man python.man | less
Andrew M. Kuchling3afe4f32004-10-07 12:30:54 +00005
Guido van Rossuma7925f11994-01-26 10:20:16 +00006.SH NAME
7python \- an interpreted, interactive, object-oriented programming language
8.SH SYNOPSIS
9.B python
10[
Matthias Klosec8b16f82010-01-31 16:14:37 +000011.B \-B
12]
13[
Senthil Kumarance3dd0b2013-06-19 22:19:46 -050014.B \-b
15]
16[
Guido van Rossuma7925f11994-01-26 10:20:16 +000017.B \-d
18]
19[
Guido van Rossumb674baf2001-09-05 18:55:34 +000020.B \-E
21]
22[
23.B \-h
24]
25[
Guido van Rossuma7925f11994-01-26 10:20:16 +000026.B \-i
27]
28[
Christian Heimesad73a9c2013-08-10 16:36:18 +020029.B \-I
Andrew M. Kuchling166e6252004-10-07 12:04:50 +000030]
Guido van Rossumb674baf2001-09-05 18:55:34 +000031.br
32 [
Christian Heimesad73a9c2013-08-10 16:36:18 +020033.B \-m
34.I module-name
35]
36[
Senthil Kumarance3dd0b2013-06-19 22:19:46 -050037.B \-q
38]
39[
Matthias Klosec8b16f82010-01-31 16:14:37 +000040.B \-O
41]
42[
R David Murray9c4f09d2011-05-01 11:13:56 -040043.B \-OO
Matthias Klosec8b16f82010-01-31 16:14:37 +000044]
45[
Matthias Klosec8b16f82010-01-31 16:14:37 +000046.B \-s
47]
48[
Guido van Rossumb674baf2001-09-05 18:55:34 +000049.B \-S
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +000050]
51[
Guido van Rossumef5bca31994-05-03 14:15:32 +000052.B \-u
Guido van Rossuma7925f11994-01-26 10:20:16 +000053]
Guido van Rossumb674baf2001-09-05 18:55:34 +000054.br
55 [
Guido van Rossuma7925f11994-01-26 10:20:16 +000056.B \-v
57]
Guido van Rossum07c44c71998-04-10 19:46:00 +000058[
Barry Warsaw64569372000-09-15 18:39:09 +000059.B \-V
60]
Guido van Rossum1378c322000-12-19 03:21:54 +000061[
62.B \-W
63.I argument
64]
Guido van Rossumb674baf2001-09-05 18:55:34 +000065[
66.B \-x
67]
Matthias Klosec8b16f82010-01-31 16:14:37 +000068[
Senthil Kumarance3dd0b2013-06-19 22:19:46 -050069[
70.B \-X
71.I option
72]
Matthias Klosec8b16f82010-01-31 16:14:37 +000073.B \-?
74]
Guido van Rossum4cf4de51997-09-08 04:06:15 +000075.br
76 [
Benjamin Peterson42aa93b2017-12-09 10:26:52 -080077.B \--check-hash-based-pycs
Miro Hrončok16323cb2019-02-25 01:50:29 +010078.I default
79|
80.I always
81|
82.I never
Benjamin Peterson42aa93b2017-12-09 10:26:52 -080083]
84.br
85 [
Guido van Rossuma7925f11994-01-26 10:20:16 +000086.B \-c
87.I command
88|
89.I script
90|
91\-
92]
93[
94.I arguments
95]
96.SH DESCRIPTION
97Python is an interpreted, interactive, object-oriented programming
98language that combines remarkable power with very clear syntax.
Benjamin Petersonb0335ee2015-04-29 18:00:44 -040099For an introduction to programming in Python, see the Python Tutorial.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000100The Python Library Reference documents built-in and standard types,
101constants, functions and modules.
102Finally, the Python Reference Manual describes the syntax and
103semantics of the core language in (perhaps too) much detail.
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000104(These documents may be located via the
105.B "INTERNET RESOURCES"
Fred Drake4c9be9d1999-08-20 13:10:20 +0000106below; they may be installed on your system as well.)
Guido van Rossuma7925f11994-01-26 10:20:16 +0000107.PP
108Python's basic power can be extended with your own modules written in
109C or C++.
Guido van Rossum74faed21996-07-30 19:27:05 +0000110On most systems such modules may be dynamically loaded.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000111Python is also adaptable as an extension language for existing
112applications.
113See the internal documentation for hints.
Andrew M. Kuchling88717f42001-04-05 14:50:40 +0000114.PP
Brett Cannonf299abd2015-04-13 14:21:02 -0400115Documentation for installed Python modules and packages can be
116viewed by running the
Andrew M. Kuchling88717f42001-04-05 14:50:40 +0000117.B pydoc
Brett Cannonf299abd2015-04-13 14:21:02 -0400118program.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000119.SH COMMAND LINE OPTIONS
120.TP
Matthias Klosec8b16f82010-01-31 16:14:37 +0000121.B \-B
122Don't write
Brett Cannon10a7dbd2016-10-21 12:15:14 -0700123.I .pyc
Matthias Klosec8b16f82010-01-31 16:14:37 +0000124files on import. See also PYTHONDONTWRITEBYTECODE.
125.TP
Senthil Kumarance3dd0b2013-06-19 22:19:46 -0500126.B \-b
127Issue warnings about str(bytes_instance), str(bytearray_instance)
128and comparing bytes/bytearray with str. (-bb: issue errors)
129.TP
Guido van Rossumb674baf2001-09-05 18:55:34 +0000130.BI "\-c " command
131Specify the command to execute (see next section).
132This terminates the option list (following options are passed as
133arguments to the command).
134.TP
Benjamin Peterson42aa93b2017-12-09 10:26:52 -0800135.BI "\-\-check-hash-based-pycs " mode
136Configure how Python evaluates the up-to-dateness of hash-based .pyc files.
137.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000138.B \-d
Victor Stinner84c4b192017-11-24 22:30:27 +0100139Turn on parser debugging output (for expert only, depending on
Guido van Rossuma7925f11994-01-26 10:20:16 +0000140compilation options).
Guido van Rossum9f65ae01994-02-23 09:10:27 +0000141.TP
Guido van Rossumb674baf2001-09-05 18:55:34 +0000142.B \-E
143Ignore environment variables like PYTHONPATH and PYTHONHOME that modify
144the behavior of the interpreter.
145.TP
Matthias Klosec8b16f82010-01-31 16:14:37 +0000146.B \-h ", " \-? ", "\-\-help
Guido van Rossumb674baf2001-09-05 18:55:34 +0000147Prints the usage for the interpreter executable and exits.
148.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000149.B \-i
150When a script is passed as first argument or the \fB\-c\fP option is
151used, enter interactive mode after executing the script or the
Guido van Rossum9f65ae01994-02-23 09:10:27 +0000152command. It does not read the $PYTHONSTARTUP file. This can be
153useful to inspect global variables or a stack trace when a script
154raises an exception.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000155.TP
Christian Heimesad73a9c2013-08-10 16:36:18 +0200156.B \-I
Ned Deily64298ae2015-04-29 14:51:43 -0700157Run Python in isolated mode. This also implies \fB\-E\fP and \fB\-s\fP. In
Serhiy Storchaka225821c2015-12-18 13:05:04 +0200158isolated mode sys.path contains neither the script's directory nor the user's
Christian Heimesad73a9c2013-08-10 16:36:18 +0200159site-packages directory. All PYTHON* environment variables are ignored, too.
160Further restrictions may be imposed to prevent the user from injecting
161malicious code.
162.TP
Andrew M. Kuchling166e6252004-10-07 12:04:50 +0000163.BI "\-m " module-name
Brett Cannonf299abd2015-04-13 14:21:02 -0400164Searches
165.I sys.path
166for the named module and runs the corresponding
167.I .py
Julien Palard202b5462021-03-31 14:31:38 +0200168file as a script. This terminates the option list (following options
169are passed as arguments to the module).
Andrew M. Kuchling166e6252004-10-07 12:04:50 +0000170.TP
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000171.B \-O
Cheryl Sabella186b6062018-02-24 22:04:40 -0500172Remove assert statements and any code conditional on the value of
173__debug__; augment the filename for compiled (bytecode) files by
174adding .opt-1 before the .pyc extension.
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000175.TP
R David Murray9c4f09d2011-05-01 11:13:56 -0400176.B \-OO
Cheryl Sabella186b6062018-02-24 22:04:40 -0500177Do \fB-O\fP and also discard docstrings; change the filename for
178compiled (bytecode) files by adding .opt-2 before the .pyc extension.
Matthias Klosec8b16f82010-01-31 16:14:37 +0000179.TP
Georg Brandl9d871192010-12-04 10:47:18 +0000180.B \-q
Brett Cannonf299abd2015-04-13 14:21:02 -0400181Do not print the version and copyright messages. These messages are
Georg Brandl9d871192010-12-04 10:47:18 +0000182also suppressed in non-interactive mode.
183.TP
Matthias Klosec8b16f82010-01-31 16:14:37 +0000184.B \-s
185Don't add user site directory to sys.path.
186.TP
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000187.B \-S
188Disable the import of the module
189.I site
190and the site-dependent manipulations of
191.I sys.path
Éric Araujoc09fca62011-03-23 02:06:24 +0100192that it entails. Also disable these manipulations if
193.I site
194is explicitly imported later.
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000195.TP
Guido van Rossumef5bca31994-05-03 14:15:32 +0000196.B \-u
Berker Peksag7f580972017-10-13 15:16:31 +0300197Force the stdout and stderr streams to be unbuffered.
198This option has no effect on the stdin stream.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000199.TP
200.B \-v
201Print a message each time a module is initialized, showing the place
Fred Drake4c9be9d1999-08-20 13:10:20 +0000202(filename or built-in module) from which it is loaded. When given
Brett Cannonf299abd2015-04-13 14:21:02 -0400203twice, print a message for each file that is checked for when
Fred Drake4c9be9d1999-08-20 13:10:20 +0000204searching for a module. Also provides information on module cleanup
205at exit.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000206.TP
Matthias Klosec8b16f82010-01-31 16:14:37 +0000207.B \-V ", " \-\-version
INADA Naoki0e175a62016-11-21 20:57:14 +0900208Prints the Python version number of the executable and exits. When given
209twice, print more information about the build.
Victor Stinner62ec6382021-04-16 19:12:14 +0200210
Barry Warsaw64569372000-09-15 18:39:09 +0000211.TP
Guido van Rossum1378c322000-12-19 03:21:54 +0000212.BI "\-W " argument
Victor Stinner62ec6382021-04-16 19:12:14 +0200213Warning control. Python's warning machinery by default prints warning messages
214to
Guido van Rossum1378c322000-12-19 03:21:54 +0000215.IR sys.stderr .
Guido van Rossum1378c322000-12-19 03:21:54 +0000216
Victor Stinner62ec6382021-04-16 19:12:14 +0200217The simplest settings apply a particular action unconditionally to all warnings
218emitted by a process (even those that are otherwise ignored by default):
Guido van Rossum1378c322000-12-19 03:21:54 +0000219
Victor Stinner62ec6382021-04-16 19:12:14 +0200220 -Wdefault # Warn once per call location
221 -Werror # Convert to exceptions
222 -Walways # Warn every time
223 -Wmodule # Warn once per calling module
224 -Wonce # Warn once per Python process
225 -Wignore # Never warn
226
227The action names can be abbreviated as desired and the interpreter will resolve
228them to the appropriate action name. For example,
229.B -Wi
230is the same as
231.B -Wignore .
232
233The full form of argument is:
234.IB action:message:category:module:lineno
235
236Empty fields match all values; trailing empty fields may be omitted. For
237example
238.B -W ignore::DeprecationWarning
239ignores all DeprecationWarning warnings.
240
241The
Guido van Rossum1378c322000-12-19 03:21:54 +0000242.I action
Victor Stinner62ec6382021-04-16 19:12:14 +0200243field is as explained above but only applies to warnings that match
244the remaining fields.
245
246The
Guido van Rossum1378c322000-12-19 03:21:54 +0000247.I message
Victor Stinner62ec6382021-04-16 19:12:14 +0200248field must match the whole printed warning message; this match is
249case-insensitive.
250
251The
Guido van Rossum1378c322000-12-19 03:21:54 +0000252.I category
Victor Stinner62ec6382021-04-16 19:12:14 +0200253field matches the warning category (ex: "DeprecationWarning"). This must be a
254class name; the match test whether the actual warning category of the message
255is a subclass of the specified warning category.
256
257The
Guido van Rossum1378c322000-12-19 03:21:54 +0000258.I module
Victor Stinner62ec6382021-04-16 19:12:14 +0200259field matches the (fully-qualified) module name; this match is case-sensitive.
260
261The
262.I lineno
263field matches the line number, where zero matches all line numbers and is thus
264equivalent to an omitted line number.
265
266Multiple
267.B -W
268options can be given; when a warning matches more than one option, the action
269for the last matching option is performed. Invalid
270.B -W
271options are ignored (though, a warning message is printed about invalid options
272when the first warning is issued).
273
274Warnings can also be controlled using the
275.B PYTHONWARNINGS
276environment variable and from within a Python program using the warnings
277module. For example, the warnings.filterwarnings() function can be used to use
278a regular expression on the warning message.
279
Guido van Rossum1378c322000-12-19 03:21:54 +0000280.TP
Senthil Kumarance3dd0b2013-06-19 22:19:46 -0500281.BI "\-X " option
Pablo Galindo41f0ef62020-01-23 01:03:04 +0000282Set implementation specific option. The following options are available:
283
284 -X faulthandler: enable faulthandler
285
286 -X showrefcount: output the total reference count and number of used
287 memory blocks when the program finishes or after each statement in the
288 interactive interpreter. This only works on debug builds
289
290 -X tracemalloc: start tracing Python memory allocations using the
291 tracemalloc module. By default, only the most recent frame is stored in a
292 traceback of a trace. Use -X tracemalloc=NFRAME to start tracing with a
293 traceback limit of NFRAME frames
294
Pablo Galindo41f0ef62020-01-23 01:03:04 +0000295 -X importtime: show how long each import takes. It shows module name,
296 cumulative time (including nested imports) and self time (excluding
297 nested imports). Note that its output may be broken in multi-threaded
298 application. Typical usage is python3 -X importtime -c 'import asyncio'
299
Serhiy Storchaka58de1dd2020-09-09 03:28:02 +0300300 -X dev: enable CPython's "development mode", introducing additional runtime
Pablo Galindo41f0ef62020-01-23 01:03:04 +0000301 checks which are too expensive to be enabled by default. It will not be
302 more verbose than the default if the code is correct: new warnings are
303 only emitted when an issue is detected. Effect of the developer mode:
304 * Add default warning filter, as -W default
305 * Install debug hooks on memory allocators: see the PyMem_SetupDebugHooks() C function
306 * Enable the faulthandler module to dump the Python traceback on a crash
307 * Enable asyncio debug mode
308 * Set the dev_mode attribute of sys.flags to True
309 * io.IOBase destructor logs close() exceptions
310
311 -X utf8: enable UTF-8 mode for operating system interfaces, overriding the default
312 locale-aware mode. -X utf8=0 explicitly disables UTF-8 mode (even when it would
313 otherwise activate automatically). See PYTHONUTF8 for more details
314
315 -X pycache_prefix=PATH: enable writing .pyc files to a parallel tree rooted at the
316 given directory instead of to the code tree.
Senthil Kumarance3dd0b2013-06-19 22:19:46 -0500317.TP
Guido van Rossumb674baf2001-09-05 18:55:34 +0000318.B \-x
319Skip the first line of the source. This is intended for a DOS
320specific hack only. Warning: the line numbers in error messages will
321be off by one!
Guido van Rossuma7925f11994-01-26 10:20:16 +0000322.SH INTERPRETER INTERFACE
323The interpreter interface resembles that of the UNIX shell: when
324called with standard input connected to a tty device, it prompts for
325commands and executes them until an EOF is read; when called with a
326file name argument or with a file as standard input, it reads and
327executes a
328.I script
329from that file;
330when called with
331.B \-c
doko@ubuntu.comd8623e82012-06-20 13:16:31 +0200332.IR command ,
Guido van Rossuma7925f11994-01-26 10:20:16 +0000333it executes the Python statement(s) given as
doko@ubuntu.comd8623e82012-06-20 13:16:31 +0200334.IR command .
Guido van Rossuma7925f11994-01-26 10:20:16 +0000335Here
336.I command
337may contain multiple statements separated by newlines.
338Leading whitespace is significant in Python statements!
Matthias Klose31a58df2005-03-20 14:16:03 +0000339In non-interactive mode, the entire input is parsed before it is
Guido van Rossuma7925f11994-01-26 10:20:16 +0000340executed.
341.PP
342If available, the script name and additional arguments thereafter are
343passed to the script in the Python variable
doko@ubuntu.comd8623e82012-06-20 13:16:31 +0200344.IR sys.argv ,
Guido van Rossuma7925f11994-01-26 10:20:16 +0000345which is a list of strings (you must first
346.I import sys
347to be able to access it).
348If no script name is given,
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000349.I sys.argv[0]
350is an empty string; if
Guido van Rossuma7925f11994-01-26 10:20:16 +0000351.B \-c
352is used,
353.I sys.argv[0]
354contains the string
355.I '-c'.
Guido van Rossum74faed21996-07-30 19:27:05 +0000356Note that options interpreted by the Python interpreter itself
Guido van Rossuma7925f11994-01-26 10:20:16 +0000357are not placed in
doko@ubuntu.comd8623e82012-06-20 13:16:31 +0200358.IR sys.argv .
Guido van Rossuma7925f11994-01-26 10:20:16 +0000359.PP
360In interactive mode, the primary prompt is `>>>'; the second prompt
361(which appears when a command is not complete) is `...'.
362The prompts can be changed by assignment to
363.I sys.ps1
364or
doko@ubuntu.comd8623e82012-06-20 13:16:31 +0200365.IR sys.ps2 .
Guido van Rossuma7925f11994-01-26 10:20:16 +0000366The interpreter quits when it reads an EOF at a prompt.
367When an unhandled exception occurs, a stack trace is printed and
368control returns to the primary prompt; in non-interactive mode, the
369interpreter exits after printing the stack trace.
370The interrupt signal raises the
371.I Keyboard\%Interrupt
372exception; other UNIX signals are not caught (except that SIGPIPE is
373sometimes ignored, in favor of the
374.I IOError
375exception). Error messages are written to stderr.
376.SH FILES AND DIRECTORIES
377These are subject to difference depending on local installation
Fred Drake4c9be9d1999-08-20 13:10:20 +0000378conventions; ${prefix} and ${exec_prefix} are installation-dependent
379and should be interpreted as for GNU software; they may be the same.
380The default for both is \fI/usr/local\fP.
381.IP \fI${exec_prefix}/bin/python\fP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000382Recommended location of the interpreter.
Fred Drake4c9be9d1999-08-20 13:10:20 +0000383.PP
384.I ${prefix}/lib/python<version>
385.br
386.I ${exec_prefix}/lib/python<version>
387.RS
388Recommended locations of the directories containing the standard
389modules.
390.RE
391.PP
392.I ${prefix}/include/python<version>
393.br
394.I ${exec_prefix}/include/python<version>
395.RS
396Recommended locations of the directories containing the include files
397needed for developing Python extensions and embedding the
398interpreter.
399.RE
Guido van Rossuma7925f11994-01-26 10:20:16 +0000400.SH ENVIRONMENT VARIABLES
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000401.IP PYTHONHOME
402Change the location of the standard Python libraries. By default, the
Fred Drake4c9be9d1999-08-20 13:10:20 +0000403libraries are searched in ${prefix}/lib/python<version> and
404${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000405are installation-dependent directories, both defaulting to
Fred Drake4c9be9d1999-08-20 13:10:20 +0000406\fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value
407replaces both ${prefix} and ${exec_prefix}. To specify different values
408for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000409.IP PYTHONPATH
410Augments the default search path for module files.
411The format is the same as the shell's $PATH: one or more directory
412pathnames separated by colons.
Matthias Klose31a58df2005-03-20 14:16:03 +0000413Non-existent directories are silently ignored.
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000414The default search path is installation dependent, but generally
Fred Drake4c9be9d1999-08-20 13:10:20 +0000415begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000416The default search path is always appended to $PYTHONPATH.
Guido van Rossum74faed21996-07-30 19:27:05 +0000417If a script argument is given, the directory containing the script is
418inserted in the path in front of $PYTHONPATH.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000419The search path can be manipulated from within a Python program as the
420variable
doko@ubuntu.comd8623e82012-06-20 13:16:31 +0200421.IR sys.path .
Sandro Mani8f023a22020-06-08 17:28:11 +0200422.IP PYTHONPLATLIBDIR
423Override sys.platlibdir.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000424.IP PYTHONSTARTUP
425If this is the name of a readable file, the Python commands in that
426file are executed before the first prompt is displayed in interactive
427mode.
428The file is executed in the same name space where interactive commands
429are executed so that objects defined or imported in it can be used
430without qualification in the interactive session.
431You can also change the prompts
432.I sys.ps1
433and
434.I sys.ps2
435in this file.
Guido van Rossum9abaf4d2001-10-12 22:17:56 +0000436.IP PYTHONOPTIMIZE
437If this is set to a non-empty string it is equivalent to specifying
438the \fB\-O\fP option. If set to an integer, it is equivalent to
439specifying \fB\-O\fP multiple times.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000440.IP PYTHONDEBUG
441If this is set to a non-empty string it is equivalent to specifying
Guido van Rossum9abaf4d2001-10-12 22:17:56 +0000442the \fB\-d\fP option. If set to an integer, it is equivalent to
443specifying \fB\-d\fP multiple times.
Matthias Klosec8b16f82010-01-31 16:14:37 +0000444.IP PYTHONDONTWRITEBYTECODE
445If this is set to a non-empty string it is equivalent to specifying
446the \fB\-B\fP option (don't try to write
Brett Cannon10a7dbd2016-10-21 12:15:14 -0700447.I .pyc
Matthias Klosec8b16f82010-01-31 16:14:37 +0000448files).
Guido van Rossuma7925f11994-01-26 10:20:16 +0000449.IP PYTHONINSPECT
450If this is set to a non-empty string it is equivalent to specifying
451the \fB\-i\fP option.
Benjamin Petersonee85a1d2010-10-13 22:20:15 +0000452.IP PYTHONIOENCODING
453If this is set before running the interpreter, it overrides the encoding used
454for stdin/stdout/stderr, in the syntax
455.IB encodingname ":" errorhandler
456The
457.IB errorhandler
458part is optional and has the same meaning as in str.encode. For stderr, the
459.IB errorhandler
460 part is ignored; the handler will always be \'backslashreplace\'.
Matthias Klosec8b16f82010-01-31 16:14:37 +0000461.IP PYTHONNOUSERSITE
Benjamin Petersonee85a1d2010-10-13 22:20:15 +0000462If this is set to a non-empty string it is equivalent to specifying the
463\fB\-s\fP option (Don't add the user site directory to sys.path).
Guido van Rossumef5bca31994-05-03 14:15:32 +0000464.IP PYTHONUNBUFFERED
Guido van Rossuma7925f11994-01-26 10:20:16 +0000465If this is set to a non-empty string it is equivalent to specifying
Guido van Rossumef5bca31994-05-03 14:15:32 +0000466the \fB\-u\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000467.IP PYTHONVERBOSE
468If this is set to a non-empty string it is equivalent to specifying
Guido van Rossum9abaf4d2001-10-12 22:17:56 +0000469the \fB\-v\fP option. If set to an integer, it is equivalent to
Brett Cannonf299abd2015-04-13 14:21:02 -0400470specifying \fB\-v\fP multiple times.
Philip Jenvey0805ca32010-04-07 04:04:10 +0000471.IP PYTHONWARNINGS
472If this is set to a comma-separated string it is equivalent to
473specifying the \fB\-W\fP option for each separate value.
Georg Brandl2daf6ae2012-02-20 19:54:16 +0100474.IP PYTHONHASHSEED
Benjamin Petersonc9f54cf2012-02-21 16:08:05 -0500475If this variable is set to "random", a random value is used to seed the hashes
Serhiy Storchakae9c90aa2019-08-24 12:49:27 +0300476of str and bytes objects.
Georg Brandl2daf6ae2012-02-20 19:54:16 +0100477
478If PYTHONHASHSEED is set to an integer value, it is used as a fixed seed for
479generating the hash() of the types covered by the hash randomization. Its
480purpose is to allow repeatable hashing, such as for selftests for the
481interpreter itself, or to allow a cluster of python processes to share hash
482values.
483
484The integer must be a decimal number in the range [0,4294967295]. Specifying
Benjamin Petersonc9f54cf2012-02-21 16:08:05 -0500485the value 0 will disable hash randomization.
Berker Peksag9863de02018-07-09 22:17:54 +0300486.IP PYTHONMALLOC
487Set the Python memory allocators and/or install debug hooks. The available
488memory allocators are
489.IR malloc
490and
491.IR pymalloc .
492The available debug hooks are
493.IR debug ,
494.IR malloc_debug ,
495and
496.IR pymalloc_debug .
497.IP
498When Python is compiled in debug mode, the default is
499.IR pymalloc_debug
500and the debug hooks are automatically used. Otherwise, the default is
501.IR pymalloc .
502.IP PYTHONMALLOCSTATS
503If set to a non-empty string, Python will print statistics of the pymalloc
504memory allocator every time a new pymalloc object arena is created, and on
505shutdown.
506.IP
507This variable is ignored if the
508.RB $ PYTHONMALLOC
509environment variable is used to force the
510.BR malloc (3)
511allocator of the C library, or if Python is configured without pymalloc support.
512.IP PYTHONASYNCIODEBUG
513If this environment variable is set to a non-empty string, enable the debug
514mode of the asyncio module.
515.IP PYTHONTRACEMALLOC
516If this environment variable is set to a non-empty string, start tracing
517Python memory allocations using the tracemalloc module.
518.IP
519The value of the variable is the maximum number of frames stored in a
520traceback of a trace. For example,
521.IB PYTHONTRACEMALLOC=1
522stores only the most recent frame.
523.IP PYTHONFAULTHANDLER
524If this environment variable is set to a non-empty string,
525.IR faulthandler.enable()
526is called at startup: install a handler for SIGSEGV, SIGFPE, SIGABRT, SIGBUS
527and SIGILL signals to dump the Python traceback.
528.IP
529This is equivalent to the \fB-X faulthandler\fP option.
530.IP PYTHONEXECUTABLE
531If this environment variable is set,
532.IB sys.argv[0]
533will be set to its value instead of the value got through the C runtime. Only
534works on Mac OS X.
535.IP PYTHONUSERBASE
536Defines the user base directory, which is used to compute the path of the user
537.IR site-packages
538directory and Distutils installation paths for
539.IR "python setup\.py install \-\-user" .
540.IP PYTHONPROFILEIMPORTTIME
541If this environment variable is set to a non-empty string, Python will
542show how long each import takes. This is exactly equivalent to setting
543\fB\-X importtime\fP on the command line.
Stéphane Wirtelb7fd7382018-07-29 12:27:16 +0200544.IP PYTHONBREAKPOINT
545If this environment variable is set to 0, it disables the default debugger. It
546can be set to the callable of your debugger of choice.
Berker Peksag9863de02018-07-09 22:17:54 +0300547.SS Debug-mode variables
548Setting these variables only has an effect in a debug build of Python, that is,
549if Python was configured with the
550\fB\--with-pydebug\fP build option.
551.IP PYTHONTHREADDEBUG
552If this environment variable is set, Python will print threading debug info.
553.IP PYTHONDUMPREFS
554If this environment variable is set, Python will dump objects and reference
555counts still alive after shutting down the interpreter.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000556.SH AUTHOR
Benjamin Peterson37c4f782015-05-10 21:19:18 -0400557The Python Software Foundation: https://www.python.org/psf/
Guido van Rossum74faed21996-07-30 19:27:05 +0000558.SH INTERNET RESOURCES
Benjamin Peterson755640b2015-04-30 17:37:11 -0400559Main website: https://www.python.org/
Guido van Rossum74faed21996-07-30 19:27:05 +0000560.br
Benjamin Peterson755640b2015-04-30 17:37:11 -0400561Documentation: https://docs.python.org/
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000562.br
Lisa Hewus Fresh384899d2017-08-30 09:37:43 -0700563Developer resources: https://devguide.python.org/
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000564.br
Benjamin Peterson755640b2015-04-30 17:37:11 -0400565Downloads: https://www.python.org/downloads/
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000566.br
Ned Deily9d6d06e2018-06-11 00:45:50 -0400567Module repository: https://pypi.org/
Guido van Rossum74faed21996-07-30 19:27:05 +0000568.br
Fred Drakebd2e3b02001-07-26 21:25:58 +0000569Newsgroups: comp.lang.python, comp.lang.python.announce
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000570.SH LICENSING
571Python is distributed under an Open Source license. See the file
572"LICENSE" in the Python source distribution for information on terms &
573conditions for accessing and otherwise using Python and for a
574DISCLAIMER OF ALL WARRANTIES.