Benjamin Peterson | b9869df | 2016-03-21 22:31:02 -0700 | [diff] [blame] | 1 | .TH PYTHON "1" |
Andrew M. Kuchling | 3afe4f3 | 2004-10-07 12:30:54 +0000 | [diff] [blame] | 2 | |
Benjamin Peterson | 5f28b7b | 2009-03-26 21:49:58 +0000 | [diff] [blame] | 3 | .\" To view this file while editing, run it through groff: |
| 4 | .\" groff -Tascii -man python.man | less |
Andrew M. Kuchling | 3afe4f3 | 2004-10-07 12:30:54 +0000 | [diff] [blame] | 5 | |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 6 | .SH NAME |
| 7 | python \- an interpreted, interactive, object-oriented programming language |
| 8 | .SH SYNOPSIS |
| 9 | .B python |
| 10 | [ |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 11 | .B \-B |
| 12 | ] |
| 13 | [ |
Senthil Kumaran | ce3dd0b | 2013-06-19 22:19:46 -0500 | [diff] [blame] | 14 | .B \-b |
| 15 | ] |
| 16 | [ |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 17 | .B \-d |
| 18 | ] |
| 19 | [ |
Guido van Rossum | b674baf | 2001-09-05 18:55:34 +0000 | [diff] [blame] | 20 | .B \-E |
| 21 | ] |
| 22 | [ |
| 23 | .B \-h |
| 24 | ] |
| 25 | [ |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 26 | .B \-i |
| 27 | ] |
| 28 | [ |
Christian Heimes | ad73a9c | 2013-08-10 16:36:18 +0200 | [diff] [blame] | 29 | .B \-I |
Andrew M. Kuchling | 166e625 | 2004-10-07 12:04:50 +0000 | [diff] [blame] | 30 | ] |
Guido van Rossum | b674baf | 2001-09-05 18:55:34 +0000 | [diff] [blame] | 31 | .br |
| 32 | [ |
Christian Heimes | ad73a9c | 2013-08-10 16:36:18 +0200 | [diff] [blame] | 33 | .B \-m |
| 34 | .I module-name |
| 35 | ] |
| 36 | [ |
Senthil Kumaran | ce3dd0b | 2013-06-19 22:19:46 -0500 | [diff] [blame] | 37 | .B \-q |
| 38 | ] |
| 39 | [ |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 40 | .B \-O |
| 41 | ] |
| 42 | [ |
R David Murray | 9c4f09d | 2011-05-01 11:13:56 -0400 | [diff] [blame] | 43 | .B \-OO |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 44 | ] |
| 45 | [ |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 46 | .B \-s |
| 47 | ] |
| 48 | [ |
Guido van Rossum | b674baf | 2001-09-05 18:55:34 +0000 | [diff] [blame] | 49 | .B \-S |
Neil Schemenauer | 7d4bb9f | 2001-07-23 16:30:27 +0000 | [diff] [blame] | 50 | ] |
| 51 | [ |
Guido van Rossum | ef5bca3 | 1994-05-03 14:15:32 +0000 | [diff] [blame] | 52 | .B \-u |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 53 | ] |
Guido van Rossum | b674baf | 2001-09-05 18:55:34 +0000 | [diff] [blame] | 54 | .br |
| 55 | [ |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 56 | .B \-v |
| 57 | ] |
Guido van Rossum | 07c44c7 | 1998-04-10 19:46:00 +0000 | [diff] [blame] | 58 | [ |
Barry Warsaw | 6456937 | 2000-09-15 18:39:09 +0000 | [diff] [blame] | 59 | .B \-V |
| 60 | ] |
Guido van Rossum | 1378c32 | 2000-12-19 03:21:54 +0000 | [diff] [blame] | 61 | [ |
| 62 | .B \-W |
| 63 | .I argument |
| 64 | ] |
Guido van Rossum | b674baf | 2001-09-05 18:55:34 +0000 | [diff] [blame] | 65 | [ |
| 66 | .B \-x |
| 67 | ] |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 68 | [ |
Senthil Kumaran | ce3dd0b | 2013-06-19 22:19:46 -0500 | [diff] [blame] | 69 | [ |
| 70 | .B \-X |
| 71 | .I option |
| 72 | ] |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 73 | .B \-? |
| 74 | ] |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 75 | .br |
| 76 | [ |
Benjamin Peterson | 42aa93b | 2017-12-09 10:26:52 -0800 | [diff] [blame] | 77 | .B \--check-hash-based-pycs |
| 78 | \'default\'|\'always\'|\'never\' |
| 79 | ] |
| 80 | .br |
| 81 | [ |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 82 | .B \-c |
| 83 | .I command |
| 84 | | |
| 85 | .I script |
| 86 | | |
| 87 | \- |
| 88 | ] |
| 89 | [ |
| 90 | .I arguments |
| 91 | ] |
| 92 | .SH DESCRIPTION |
| 93 | Python is an interpreted, interactive, object-oriented programming |
| 94 | language that combines remarkable power with very clear syntax. |
Benjamin Peterson | b0335ee | 2015-04-29 18:00:44 -0400 | [diff] [blame] | 95 | For an introduction to programming in Python, see the Python Tutorial. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 96 | The Python Library Reference documents built-in and standard types, |
| 97 | constants, functions and modules. |
| 98 | Finally, the Python Reference Manual describes the syntax and |
| 99 | semantics of the core language in (perhaps too) much detail. |
Guido van Rossum | f4a090d | 2000-09-01 20:36:34 +0000 | [diff] [blame] | 100 | (These documents may be located via the |
| 101 | .B "INTERNET RESOURCES" |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 102 | below; they may be installed on your system as well.) |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 103 | .PP |
| 104 | Python's basic power can be extended with your own modules written in |
| 105 | C or C++. |
Guido van Rossum | 74faed2 | 1996-07-30 19:27:05 +0000 | [diff] [blame] | 106 | On most systems such modules may be dynamically loaded. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 107 | Python is also adaptable as an extension language for existing |
| 108 | applications. |
| 109 | See the internal documentation for hints. |
Andrew M. Kuchling | 88717f4 | 2001-04-05 14:50:40 +0000 | [diff] [blame] | 110 | .PP |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 111 | Documentation for installed Python modules and packages can be |
| 112 | viewed by running the |
Andrew M. Kuchling | 88717f4 | 2001-04-05 14:50:40 +0000 | [diff] [blame] | 113 | .B pydoc |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 114 | program. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 115 | .SH COMMAND LINE OPTIONS |
| 116 | .TP |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 117 | .B \-B |
| 118 | Don't write |
Brett Cannon | 10a7dbd | 2016-10-21 12:15:14 -0700 | [diff] [blame] | 119 | .I .pyc |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 120 | files on import. See also PYTHONDONTWRITEBYTECODE. |
| 121 | .TP |
Senthil Kumaran | ce3dd0b | 2013-06-19 22:19:46 -0500 | [diff] [blame] | 122 | .B \-b |
| 123 | Issue warnings about str(bytes_instance), str(bytearray_instance) |
| 124 | and comparing bytes/bytearray with str. (-bb: issue errors) |
| 125 | .TP |
Guido van Rossum | b674baf | 2001-09-05 18:55:34 +0000 | [diff] [blame] | 126 | .BI "\-c " command |
| 127 | Specify the command to execute (see next section). |
| 128 | This terminates the option list (following options are passed as |
| 129 | arguments to the command). |
| 130 | .TP |
Benjamin Peterson | 42aa93b | 2017-12-09 10:26:52 -0800 | [diff] [blame] | 131 | .BI "\-\-check-hash-based-pycs " mode |
| 132 | Configure how Python evaluates the up-to-dateness of hash-based .pyc files. |
| 133 | .TP |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 134 | .B \-d |
Victor Stinner | 84c4b19 | 2017-11-24 22:30:27 +0100 | [diff] [blame] | 135 | Turn on parser debugging output (for expert only, depending on |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 136 | compilation options). |
Guido van Rossum | 9f65ae0 | 1994-02-23 09:10:27 +0000 | [diff] [blame] | 137 | .TP |
Guido van Rossum | b674baf | 2001-09-05 18:55:34 +0000 | [diff] [blame] | 138 | .B \-E |
| 139 | Ignore environment variables like PYTHONPATH and PYTHONHOME that modify |
| 140 | the behavior of the interpreter. |
| 141 | .TP |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 142 | .B \-h ", " \-? ", "\-\-help |
Guido van Rossum | b674baf | 2001-09-05 18:55:34 +0000 | [diff] [blame] | 143 | Prints the usage for the interpreter executable and exits. |
| 144 | .TP |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 145 | .B \-i |
| 146 | When a script is passed as first argument or the \fB\-c\fP option is |
| 147 | used, enter interactive mode after executing the script or the |
Guido van Rossum | 9f65ae0 | 1994-02-23 09:10:27 +0000 | [diff] [blame] | 148 | command. It does not read the $PYTHONSTARTUP file. This can be |
| 149 | useful to inspect global variables or a stack trace when a script |
| 150 | raises an exception. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 151 | .TP |
Christian Heimes | ad73a9c | 2013-08-10 16:36:18 +0200 | [diff] [blame] | 152 | .B \-I |
Ned Deily | 64298ae | 2015-04-29 14:51:43 -0700 | [diff] [blame] | 153 | Run Python in isolated mode. This also implies \fB\-E\fP and \fB\-s\fP. In |
Serhiy Storchaka | 225821c | 2015-12-18 13:05:04 +0200 | [diff] [blame] | 154 | isolated mode sys.path contains neither the script's directory nor the user's |
Christian Heimes | ad73a9c | 2013-08-10 16:36:18 +0200 | [diff] [blame] | 155 | site-packages directory. All PYTHON* environment variables are ignored, too. |
| 156 | Further restrictions may be imposed to prevent the user from injecting |
| 157 | malicious code. |
| 158 | .TP |
Andrew M. Kuchling | 166e625 | 2004-10-07 12:04:50 +0000 | [diff] [blame] | 159 | .BI "\-m " module-name |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 160 | Searches |
| 161 | .I sys.path |
| 162 | for the named module and runs the corresponding |
| 163 | .I .py |
Andrew M. Kuchling | 166e625 | 2004-10-07 12:04:50 +0000 | [diff] [blame] | 164 | file as a script. |
| 165 | .TP |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 166 | .B \-O |
Cheryl Sabella | 186b606 | 2018-02-24 22:04:40 -0500 | [diff] [blame] | 167 | Remove assert statements and any code conditional on the value of |
| 168 | __debug__; augment the filename for compiled (bytecode) files by |
| 169 | adding .opt-1 before the .pyc extension. |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 170 | .TP |
R David Murray | 9c4f09d | 2011-05-01 11:13:56 -0400 | [diff] [blame] | 171 | .B \-OO |
Cheryl Sabella | 186b606 | 2018-02-24 22:04:40 -0500 | [diff] [blame] | 172 | Do \fB-O\fP and also discard docstrings; change the filename for |
| 173 | compiled (bytecode) files by adding .opt-2 before the .pyc extension. |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 174 | .TP |
Georg Brandl | 9d87119 | 2010-12-04 10:47:18 +0000 | [diff] [blame] | 175 | .B \-q |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 176 | Do not print the version and copyright messages. These messages are |
Georg Brandl | 9d87119 | 2010-12-04 10:47:18 +0000 | [diff] [blame] | 177 | also suppressed in non-interactive mode. |
| 178 | .TP |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 179 | .B \-s |
| 180 | Don't add user site directory to sys.path. |
| 181 | .TP |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 182 | .B \-S |
| 183 | Disable the import of the module |
| 184 | .I site |
| 185 | and the site-dependent manipulations of |
| 186 | .I sys.path |
Éric Araujo | c09fca6 | 2011-03-23 02:06:24 +0100 | [diff] [blame] | 187 | that it entails. Also disable these manipulations if |
| 188 | .I site |
| 189 | is explicitly imported later. |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 190 | .TP |
Guido van Rossum | ef5bca3 | 1994-05-03 14:15:32 +0000 | [diff] [blame] | 191 | .B \-u |
Berker Peksag | 7f58097 | 2017-10-13 15:16:31 +0300 | [diff] [blame] | 192 | Force the stdout and stderr streams to be unbuffered. |
| 193 | This option has no effect on the stdin stream. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 194 | .TP |
| 195 | .B \-v |
| 196 | Print a message each time a module is initialized, showing the place |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 197 | (filename or built-in module) from which it is loaded. When given |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 198 | twice, print a message for each file that is checked for when |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 199 | searching for a module. Also provides information on module cleanup |
| 200 | at exit. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 201 | .TP |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 202 | .B \-V ", " \-\-version |
INADA Naoki | 0e175a6 | 2016-11-21 20:57:14 +0900 | [diff] [blame] | 203 | Prints the Python version number of the executable and exits. When given |
| 204 | twice, print more information about the build. |
Barry Warsaw | 6456937 | 2000-09-15 18:39:09 +0000 | [diff] [blame] | 205 | .TP |
Guido van Rossum | 1378c32 | 2000-12-19 03:21:54 +0000 | [diff] [blame] | 206 | .BI "\-W " argument |
| 207 | Warning control. Python sometimes prints warning message to |
| 208 | .IR sys.stderr . |
| 209 | A typical warning message has the following form: |
| 210 | .IB file ":" line ": " category ": " message. |
| 211 | By default, each warning is printed once for each source line where it |
| 212 | occurs. This option controls how often warnings are printed. |
| 213 | Multiple |
| 214 | .B \-W |
| 215 | options may be given; when a warning matches more than one |
| 216 | option, the action for the last matching option is performed. |
| 217 | Invalid |
| 218 | .B \-W |
| 219 | options are ignored (a warning message is printed about invalid |
| 220 | options when the first warning is issued). Warnings can also be |
| 221 | controlled from within a Python program using the |
| 222 | .I warnings |
| 223 | module. |
| 224 | |
| 225 | The simplest form of |
| 226 | .I argument |
| 227 | is one of the following |
| 228 | .I action |
| 229 | strings (or a unique abbreviation): |
| 230 | .B ignore |
| 231 | to ignore all warnings; |
| 232 | .B default |
| 233 | to explicitly request the default behavior (printing each warning once |
| 234 | per source line); |
| 235 | .B all |
| 236 | to print a warning each time it occurs (this may generate many |
| 237 | messages if a warning is triggered repeatedly for the same source |
Fred Drake | bd2e3b0 | 2001-07-26 21:25:58 +0000 | [diff] [blame] | 238 | line, such as inside a loop); |
Guido van Rossum | 1378c32 | 2000-12-19 03:21:54 +0000 | [diff] [blame] | 239 | .B module |
Georg Brandl | eeb575f | 2009-06-24 06:42:05 +0000 | [diff] [blame] | 240 | to print each warning only the first time it occurs in each |
Guido van Rossum | 1378c32 | 2000-12-19 03:21:54 +0000 | [diff] [blame] | 241 | module; |
| 242 | .B once |
| 243 | to print each warning only the first time it occurs in the program; or |
| 244 | .B error |
| 245 | to raise an exception instead of printing a warning message. |
| 246 | |
| 247 | The full form of |
| 248 | .I argument |
| 249 | is |
| 250 | .IB action : message : category : module : line. |
| 251 | Here, |
| 252 | .I action |
| 253 | is as explained above but only applies to messages that match the |
| 254 | remaining fields. Empty fields match all values; trailing empty |
| 255 | fields may be omitted. The |
| 256 | .I message |
| 257 | field matches the start of the warning message printed; this match is |
| 258 | case-insensitive. The |
| 259 | .I category |
| 260 | field matches the warning category. This must be a class name; the |
| 261 | match test whether the actual warning category of the message is a |
| 262 | subclass of the specified warning category. The full class name must |
| 263 | be given. The |
| 264 | .I module |
| 265 | field matches the (fully-qualified) module name; this match is |
| 266 | case-sensitive. The |
| 267 | .I line |
| 268 | field matches the line number, where zero matches all line numbers and |
| 269 | is thus equivalent to an omitted line number. |
| 270 | .TP |
Senthil Kumaran | ce3dd0b | 2013-06-19 22:19:46 -0500 | [diff] [blame] | 271 | .BI "\-X " option |
| 272 | Set implementation specific option. |
| 273 | .TP |
Guido van Rossum | b674baf | 2001-09-05 18:55:34 +0000 | [diff] [blame] | 274 | .B \-x |
| 275 | Skip the first line of the source. This is intended for a DOS |
| 276 | specific hack only. Warning: the line numbers in error messages will |
| 277 | be off by one! |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 278 | .SH INTERPRETER INTERFACE |
| 279 | The interpreter interface resembles that of the UNIX shell: when |
| 280 | called with standard input connected to a tty device, it prompts for |
| 281 | commands and executes them until an EOF is read; when called with a |
| 282 | file name argument or with a file as standard input, it reads and |
| 283 | executes a |
| 284 | .I script |
| 285 | from that file; |
| 286 | when called with |
| 287 | .B \-c |
doko@ubuntu.com | d8623e8 | 2012-06-20 13:16:31 +0200 | [diff] [blame] | 288 | .IR command , |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 289 | it executes the Python statement(s) given as |
doko@ubuntu.com | d8623e8 | 2012-06-20 13:16:31 +0200 | [diff] [blame] | 290 | .IR command . |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 291 | Here |
| 292 | .I command |
| 293 | may contain multiple statements separated by newlines. |
| 294 | Leading whitespace is significant in Python statements! |
Matthias Klose | 31a58df | 2005-03-20 14:16:03 +0000 | [diff] [blame] | 295 | In non-interactive mode, the entire input is parsed before it is |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 296 | executed. |
| 297 | .PP |
| 298 | If available, the script name and additional arguments thereafter are |
| 299 | passed to the script in the Python variable |
doko@ubuntu.com | d8623e8 | 2012-06-20 13:16:31 +0200 | [diff] [blame] | 300 | .IR sys.argv , |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 301 | which is a list of strings (you must first |
| 302 | .I import sys |
| 303 | to be able to access it). |
| 304 | If no script name is given, |
Guido van Rossum | f4a090d | 2000-09-01 20:36:34 +0000 | [diff] [blame] | 305 | .I sys.argv[0] |
| 306 | is an empty string; if |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 307 | .B \-c |
| 308 | is used, |
| 309 | .I sys.argv[0] |
| 310 | contains the string |
| 311 | .I '-c'. |
Guido van Rossum | 74faed2 | 1996-07-30 19:27:05 +0000 | [diff] [blame] | 312 | Note that options interpreted by the Python interpreter itself |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 313 | are not placed in |
doko@ubuntu.com | d8623e8 | 2012-06-20 13:16:31 +0200 | [diff] [blame] | 314 | .IR sys.argv . |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 315 | .PP |
| 316 | In interactive mode, the primary prompt is `>>>'; the second prompt |
| 317 | (which appears when a command is not complete) is `...'. |
| 318 | The prompts can be changed by assignment to |
| 319 | .I sys.ps1 |
| 320 | or |
doko@ubuntu.com | d8623e8 | 2012-06-20 13:16:31 +0200 | [diff] [blame] | 321 | .IR sys.ps2 . |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 322 | The interpreter quits when it reads an EOF at a prompt. |
| 323 | When an unhandled exception occurs, a stack trace is printed and |
| 324 | control returns to the primary prompt; in non-interactive mode, the |
| 325 | interpreter exits after printing the stack trace. |
| 326 | The interrupt signal raises the |
| 327 | .I Keyboard\%Interrupt |
| 328 | exception; other UNIX signals are not caught (except that SIGPIPE is |
| 329 | sometimes ignored, in favor of the |
| 330 | .I IOError |
| 331 | exception). Error messages are written to stderr. |
| 332 | .SH FILES AND DIRECTORIES |
| 333 | These are subject to difference depending on local installation |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 334 | conventions; ${prefix} and ${exec_prefix} are installation-dependent |
| 335 | and should be interpreted as for GNU software; they may be the same. |
| 336 | The default for both is \fI/usr/local\fP. |
| 337 | .IP \fI${exec_prefix}/bin/python\fP |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 338 | Recommended location of the interpreter. |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 339 | .PP |
| 340 | .I ${prefix}/lib/python<version> |
| 341 | .br |
| 342 | .I ${exec_prefix}/lib/python<version> |
| 343 | .RS |
| 344 | Recommended locations of the directories containing the standard |
| 345 | modules. |
| 346 | .RE |
| 347 | .PP |
| 348 | .I ${prefix}/include/python<version> |
| 349 | .br |
| 350 | .I ${exec_prefix}/include/python<version> |
| 351 | .RS |
| 352 | Recommended locations of the directories containing the include files |
| 353 | needed for developing Python extensions and embedding the |
| 354 | interpreter. |
| 355 | .RE |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 356 | .SH ENVIRONMENT VARIABLES |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 357 | .IP PYTHONHOME |
| 358 | Change the location of the standard Python libraries. By default, the |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 359 | libraries are searched in ${prefix}/lib/python<version> and |
| 360 | ${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix} |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 361 | are installation-dependent directories, both defaulting to |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 362 | \fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value |
| 363 | replaces both ${prefix} and ${exec_prefix}. To specify different values |
| 364 | for these, set $PYTHONHOME to ${prefix}:${exec_prefix}. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 365 | .IP PYTHONPATH |
| 366 | Augments the default search path for module files. |
| 367 | The format is the same as the shell's $PATH: one or more directory |
| 368 | pathnames separated by colons. |
Matthias Klose | 31a58df | 2005-03-20 14:16:03 +0000 | [diff] [blame] | 369 | Non-existent directories are silently ignored. |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 370 | The default search path is installation dependent, but generally |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 371 | begins with ${prefix}/lib/python<version> (see PYTHONHOME above). |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 372 | The default search path is always appended to $PYTHONPATH. |
Guido van Rossum | 74faed2 | 1996-07-30 19:27:05 +0000 | [diff] [blame] | 373 | If a script argument is given, the directory containing the script is |
| 374 | inserted in the path in front of $PYTHONPATH. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 375 | The search path can be manipulated from within a Python program as the |
| 376 | variable |
doko@ubuntu.com | d8623e8 | 2012-06-20 13:16:31 +0200 | [diff] [blame] | 377 | .IR sys.path . |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 378 | .IP PYTHONSTARTUP |
| 379 | If this is the name of a readable file, the Python commands in that |
| 380 | file are executed before the first prompt is displayed in interactive |
| 381 | mode. |
| 382 | The file is executed in the same name space where interactive commands |
| 383 | are executed so that objects defined or imported in it can be used |
| 384 | without qualification in the interactive session. |
| 385 | You can also change the prompts |
| 386 | .I sys.ps1 |
| 387 | and |
| 388 | .I sys.ps2 |
| 389 | in this file. |
Guido van Rossum | 9abaf4d | 2001-10-12 22:17:56 +0000 | [diff] [blame] | 390 | .IP PYTHONOPTIMIZE |
| 391 | If this is set to a non-empty string it is equivalent to specifying |
| 392 | the \fB\-O\fP option. If set to an integer, it is equivalent to |
| 393 | specifying \fB\-O\fP multiple times. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 394 | .IP PYTHONDEBUG |
| 395 | If this is set to a non-empty string it is equivalent to specifying |
Guido van Rossum | 9abaf4d | 2001-10-12 22:17:56 +0000 | [diff] [blame] | 396 | the \fB\-d\fP option. If set to an integer, it is equivalent to |
| 397 | specifying \fB\-d\fP multiple times. |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 398 | .IP PYTHONDONTWRITEBYTECODE |
| 399 | If this is set to a non-empty string it is equivalent to specifying |
| 400 | the \fB\-B\fP option (don't try to write |
Brett Cannon | 10a7dbd | 2016-10-21 12:15:14 -0700 | [diff] [blame] | 401 | .I .pyc |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 402 | files). |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 403 | .IP PYTHONINSPECT |
| 404 | If this is set to a non-empty string it is equivalent to specifying |
| 405 | the \fB\-i\fP option. |
Benjamin Peterson | ee85a1d | 2010-10-13 22:20:15 +0000 | [diff] [blame] | 406 | .IP PYTHONIOENCODING |
| 407 | If this is set before running the interpreter, it overrides the encoding used |
| 408 | for stdin/stdout/stderr, in the syntax |
| 409 | .IB encodingname ":" errorhandler |
| 410 | The |
| 411 | .IB errorhandler |
| 412 | part is optional and has the same meaning as in str.encode. For stderr, the |
| 413 | .IB errorhandler |
| 414 | part is ignored; the handler will always be \'backslashreplace\'. |
Matthias Klose | c8b16f8 | 2010-01-31 16:14:37 +0000 | [diff] [blame] | 415 | .IP PYTHONNOUSERSITE |
Benjamin Peterson | ee85a1d | 2010-10-13 22:20:15 +0000 | [diff] [blame] | 416 | If this is set to a non-empty string it is equivalent to specifying the |
| 417 | \fB\-s\fP option (Don't add the user site directory to sys.path). |
Guido van Rossum | ef5bca3 | 1994-05-03 14:15:32 +0000 | [diff] [blame] | 418 | .IP PYTHONUNBUFFERED |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 419 | If this is set to a non-empty string it is equivalent to specifying |
Guido van Rossum | ef5bca3 | 1994-05-03 14:15:32 +0000 | [diff] [blame] | 420 | the \fB\-u\fP option. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 421 | .IP PYTHONVERBOSE |
| 422 | If this is set to a non-empty string it is equivalent to specifying |
Guido van Rossum | 9abaf4d | 2001-10-12 22:17:56 +0000 | [diff] [blame] | 423 | the \fB\-v\fP option. If set to an integer, it is equivalent to |
Brett Cannon | f299abd | 2015-04-13 14:21:02 -0400 | [diff] [blame] | 424 | specifying \fB\-v\fP multiple times. |
Philip Jenvey | 0805ca3 | 2010-04-07 04:04:10 +0000 | [diff] [blame] | 425 | .IP PYTHONWARNINGS |
| 426 | If this is set to a comma-separated string it is equivalent to |
| 427 | specifying the \fB\-W\fP option for each separate value. |
Georg Brandl | 2daf6ae | 2012-02-20 19:54:16 +0100 | [diff] [blame] | 428 | .IP PYTHONHASHSEED |
Benjamin Peterson | c9f54cf | 2012-02-21 16:08:05 -0500 | [diff] [blame] | 429 | If this variable is set to "random", a random value is used to seed the hashes |
| 430 | of str, bytes and datetime objects. |
Georg Brandl | 2daf6ae | 2012-02-20 19:54:16 +0100 | [diff] [blame] | 431 | |
| 432 | If PYTHONHASHSEED is set to an integer value, it is used as a fixed seed for |
| 433 | generating the hash() of the types covered by the hash randomization. Its |
| 434 | purpose is to allow repeatable hashing, such as for selftests for the |
| 435 | interpreter itself, or to allow a cluster of python processes to share hash |
| 436 | values. |
| 437 | |
| 438 | The integer must be a decimal number in the range [0,4294967295]. Specifying |
Benjamin Peterson | c9f54cf | 2012-02-21 16:08:05 -0500 | [diff] [blame] | 439 | the value 0 will disable hash randomization. |
Berker Peksag | 9863de0 | 2018-07-09 22:17:54 +0300 | [diff] [blame] | 440 | .IP PYTHONMALLOC |
| 441 | Set the Python memory allocators and/or install debug hooks. The available |
| 442 | memory allocators are |
| 443 | .IR malloc |
| 444 | and |
| 445 | .IR pymalloc . |
| 446 | The available debug hooks are |
| 447 | .IR debug , |
| 448 | .IR malloc_debug , |
| 449 | and |
| 450 | .IR pymalloc_debug . |
| 451 | .IP |
| 452 | When Python is compiled in debug mode, the default is |
| 453 | .IR pymalloc_debug |
| 454 | and the debug hooks are automatically used. Otherwise, the default is |
| 455 | .IR pymalloc . |
| 456 | .IP PYTHONMALLOCSTATS |
| 457 | If set to a non-empty string, Python will print statistics of the pymalloc |
| 458 | memory allocator every time a new pymalloc object arena is created, and on |
| 459 | shutdown. |
| 460 | .IP |
| 461 | This variable is ignored if the |
| 462 | .RB $ PYTHONMALLOC |
| 463 | environment variable is used to force the |
| 464 | .BR malloc (3) |
| 465 | allocator of the C library, or if Python is configured without pymalloc support. |
| 466 | .IP PYTHONASYNCIODEBUG |
| 467 | If this environment variable is set to a non-empty string, enable the debug |
| 468 | mode of the asyncio module. |
| 469 | .IP PYTHONTRACEMALLOC |
| 470 | If this environment variable is set to a non-empty string, start tracing |
| 471 | Python memory allocations using the tracemalloc module. |
| 472 | .IP |
| 473 | The value of the variable is the maximum number of frames stored in a |
| 474 | traceback of a trace. For example, |
| 475 | .IB PYTHONTRACEMALLOC=1 |
| 476 | stores only the most recent frame. |
| 477 | .IP PYTHONFAULTHANDLER |
| 478 | If this environment variable is set to a non-empty string, |
| 479 | .IR faulthandler.enable() |
| 480 | is called at startup: install a handler for SIGSEGV, SIGFPE, SIGABRT, SIGBUS |
| 481 | and SIGILL signals to dump the Python traceback. |
| 482 | .IP |
| 483 | This is equivalent to the \fB-X faulthandler\fP option. |
| 484 | .IP PYTHONEXECUTABLE |
| 485 | If this environment variable is set, |
| 486 | .IB sys.argv[0] |
| 487 | will be set to its value instead of the value got through the C runtime. Only |
| 488 | works on Mac OS X. |
| 489 | .IP PYTHONUSERBASE |
| 490 | Defines the user base directory, which is used to compute the path of the user |
| 491 | .IR site-packages |
| 492 | directory and Distutils installation paths for |
| 493 | .IR "python setup\.py install \-\-user" . |
| 494 | .IP PYTHONPROFILEIMPORTTIME |
| 495 | If this environment variable is set to a non-empty string, Python will |
| 496 | show how long each import takes. This is exactly equivalent to setting |
| 497 | \fB\-X importtime\fP on the command line. |
Stéphane Wirtel | b7fd738 | 2018-07-29 12:27:16 +0200 | [diff] [blame] | 498 | .IP PYTHONBREAKPOINT |
| 499 | If this environment variable is set to 0, it disables the default debugger. It |
| 500 | can be set to the callable of your debugger of choice. |
Berker Peksag | 9863de0 | 2018-07-09 22:17:54 +0300 | [diff] [blame] | 501 | .SS Debug-mode variables |
| 502 | Setting these variables only has an effect in a debug build of Python, that is, |
| 503 | if Python was configured with the |
| 504 | \fB\--with-pydebug\fP build option. |
| 505 | .IP PYTHONTHREADDEBUG |
| 506 | If this environment variable is set, Python will print threading debug info. |
| 507 | .IP PYTHONDUMPREFS |
| 508 | If this environment variable is set, Python will dump objects and reference |
| 509 | counts still alive after shutting down the interpreter. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 510 | .SH AUTHOR |
Benjamin Peterson | 37c4f78 | 2015-05-10 21:19:18 -0400 | [diff] [blame] | 511 | The Python Software Foundation: https://www.python.org/psf/ |
Guido van Rossum | 74faed2 | 1996-07-30 19:27:05 +0000 | [diff] [blame] | 512 | .SH INTERNET RESOURCES |
Benjamin Peterson | 755640b | 2015-04-30 17:37:11 -0400 | [diff] [blame] | 513 | Main website: https://www.python.org/ |
Guido van Rossum | 74faed2 | 1996-07-30 19:27:05 +0000 | [diff] [blame] | 514 | .br |
Benjamin Peterson | 755640b | 2015-04-30 17:37:11 -0400 | [diff] [blame] | 515 | Documentation: https://docs.python.org/ |
Guido van Rossum | f4a090d | 2000-09-01 20:36:34 +0000 | [diff] [blame] | 516 | .br |
Lisa Hewus Fresh | 384899d | 2017-08-30 09:37:43 -0700 | [diff] [blame] | 517 | Developer resources: https://devguide.python.org/ |
Guido van Rossum | f4a090d | 2000-09-01 20:36:34 +0000 | [diff] [blame] | 518 | .br |
Benjamin Peterson | 755640b | 2015-04-30 17:37:11 -0400 | [diff] [blame] | 519 | Downloads: https://www.python.org/downloads/ |
Guido van Rossum | f4a090d | 2000-09-01 20:36:34 +0000 | [diff] [blame] | 520 | .br |
Ned Deily | 9d6d06e | 2018-06-11 00:45:50 -0400 | [diff] [blame] | 521 | Module repository: https://pypi.org/ |
Guido van Rossum | 74faed2 | 1996-07-30 19:27:05 +0000 | [diff] [blame] | 522 | .br |
Fred Drake | bd2e3b0 | 2001-07-26 21:25:58 +0000 | [diff] [blame] | 523 | Newsgroups: comp.lang.python, comp.lang.python.announce |
Guido van Rossum | f4a090d | 2000-09-01 20:36:34 +0000 | [diff] [blame] | 524 | .SH LICENSING |
| 525 | Python is distributed under an Open Source license. See the file |
| 526 | "LICENSE" in the Python source distribution for information on terms & |
| 527 | conditions for accessing and otherwise using Python and for a |
| 528 | DISCLAIMER OF ALL WARRANTIES. |