gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1447 lines
123KB

  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <meta property="og:title" content="1. Command line and environment" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/using/cmdline.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="The CPython interpreter scans the command line and the environment for various settings. CPython implementation detail: Other implementations’ command line schemes may differ. See Alternate Impleme..." />
  11. <meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
  12. <meta property="og:image:alt" content="Python documentation" />
  13. <meta name="description" content="The CPython interpreter scans the command line and the environment for various settings. CPython implementation detail: Other implementations’ command line schemes may differ. See Alternate Impleme..." />
  14. <meta property="og:image:width" content="200" />
  15. <meta property="og:image:height" content="200" />
  16. <meta name="theme-color" content="#3776ab" />
  17. <title>1. Command line and environment &#8212; Python 3.12.3 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
  19. <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=bb723527" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=b20cc3f5" />
  21. <script src="../_static/documentation_options.js?v=2c828074"></script>
  22. <script src="../_static/doctools.js?v=888ff710"></script>
  23. <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
  24. <script src="../_static/sidebar.js"></script>
  25. <link rel="search" type="application/opensearchdescription+xml"
  26. title="Search within Python 3.12.3 documentation"
  27. href="../_static/opensearch.xml"/>
  28. <link rel="author" title="About these documents" href="../about.html" />
  29. <link rel="index" title="Index" href="../genindex.html" />
  30. <link rel="search" title="Search" href="../search.html" />
  31. <link rel="copyright" title="Copyright" href="../copyright.html" />
  32. <link rel="next" title="2. Using Python on Unix platforms" href="unix.html" />
  33. <link rel="prev" title="Python Setup and Usage" href="index.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/using/cmdline.html" />
  35. <style>
  36. @media only screen {
  37. table.full-width-table {
  38. width: 100%;
  39. }
  40. }
  41. </style>
  42. <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  43. <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
  44. <script type="text/javascript" src="../_static/copybutton.js"></script>
  45. <script type="text/javascript" src="../_static/menu.js"></script>
  46. <script type="text/javascript" src="../_static/search-focus.js"></script>
  47. <script type="text/javascript" src="../_static/themetoggle.js"></script>
  48. </head>
  49. <body>
  50. <div class="mobile-nav">
  51. <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
  52. aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
  53. <nav class="nav-content" role="navigation">
  54. <label for="menuToggler" class="toggler__label">
  55. <span></span>
  56. </label>
  57. <span class="nav-items-wrapper">
  58. <a href="https://www.python.org/" class="nav-logo">
  59. <img src="../_static/py.svg" alt="Python logo"/>
  60. </a>
  61. <span class="version_switcher_placeholder"></span>
  62. <form role="search" class="search" action="../search.html" method="get">
  63. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
  64. <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
  65. </svg>
  66. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  67. <input type="submit" value="Go"/>
  68. </form>
  69. </span>
  70. </nav>
  71. <div class="menu-wrapper">
  72. <nav class="menu" role="navigation" aria-label="main navigation">
  73. <div class="language_switcher_placeholder"></div>
  74. <label class="theme-selector-label">
  75. Theme
  76. <select class="theme-selector" oninput="activateTheme(this.value)">
  77. <option value="auto" selected>Auto</option>
  78. <option value="light">Light</option>
  79. <option value="dark">Dark</option>
  80. </select>
  81. </label>
  82. <div>
  83. <h3><a href="../contents.html">Table of Contents</a></h3>
  84. <ul>
  85. <li><a class="reference internal" href="#">1. Command line and environment</a><ul>
  86. <li><a class="reference internal" href="#command-line">1.1. Command line</a><ul>
  87. <li><a class="reference internal" href="#interface-options">1.1.1. Interface options</a></li>
  88. <li><a class="reference internal" href="#generic-options">1.1.2. Generic options</a></li>
  89. <li><a class="reference internal" href="#miscellaneous-options">1.1.3. Miscellaneous options</a></li>
  90. <li><a class="reference internal" href="#options-you-shouldn-t-use">1.1.4. Options you shouldn’t use</a></li>
  91. </ul>
  92. </li>
  93. <li><a class="reference internal" href="#environment-variables">1.2. Environment variables</a><ul>
  94. <li><a class="reference internal" href="#debug-mode-variables">1.2.1. Debug-mode variables</a></li>
  95. </ul>
  96. </li>
  97. </ul>
  98. </li>
  99. </ul>
  100. </div>
  101. <div>
  102. <h4>Previous topic</h4>
  103. <p class="topless"><a href="index.html"
  104. title="previous chapter">Python Setup and Usage</a></p>
  105. </div>
  106. <div>
  107. <h4>Next topic</h4>
  108. <p class="topless"><a href="unix.html"
  109. title="next chapter"><span class="section-number">2. </span>Using Python on Unix platforms</a></p>
  110. </div>
  111. <div role="note" aria-label="source link">
  112. <h3>This Page</h3>
  113. <ul class="this-page-menu">
  114. <li><a href="../bugs.html">Report a Bug</a></li>
  115. <li>
  116. <a href="https://github.com/python/cpython/blob/main/Doc/using/cmdline.rst"
  117. rel="nofollow">Show Source
  118. </a>
  119. </li>
  120. </ul>
  121. </div>
  122. </nav>
  123. </div>
  124. </div>
  125. <div class="related" role="navigation" aria-label="related navigation">
  126. <h3>Navigation</h3>
  127. <ul>
  128. <li class="right" style="margin-right: 10px">
  129. <a href="../genindex.html" title="General Index"
  130. accesskey="I">index</a></li>
  131. <li class="right" >
  132. <a href="../py-modindex.html" title="Python Module Index"
  133. >modules</a> |</li>
  134. <li class="right" >
  135. <a href="unix.html" title="2. Using Python on Unix platforms"
  136. accesskey="N">next</a> |</li>
  137. <li class="right" >
  138. <a href="index.html" title="Python Setup and Usage"
  139. accesskey="P">previous</a> |</li>
  140. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  141. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  142. <li class="switchers">
  143. <div class="language_switcher_placeholder"></div>
  144. <div class="version_switcher_placeholder"></div>
  145. </li>
  146. <li>
  147. </li>
  148. <li id="cpython-language-and-version">
  149. <a href="../index.html">3.12.3 Documentation</a> &#187;
  150. </li>
  151. <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Python Setup and Usage</a> &#187;</li>
  152. <li class="nav-item nav-item-this"><a href=""><span class="section-number">1. </span>Command line and environment</a></li>
  153. <li class="right">
  154. <div class="inline-search" role="search">
  155. <form class="inline-search" action="../search.html" method="get">
  156. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  157. <input type="submit" value="Go" />
  158. </form>
  159. </div>
  160. |
  161. </li>
  162. <li class="right">
  163. <label class="theme-selector-label">
  164. Theme
  165. <select class="theme-selector" oninput="activateTheme(this.value)">
  166. <option value="auto" selected>Auto</option>
  167. <option value="light">Light</option>
  168. <option value="dark">Dark</option>
  169. </select>
  170. </label> |</li>
  171. </ul>
  172. </div>
  173. <div class="document">
  174. <div class="documentwrapper">
  175. <div class="bodywrapper">
  176. <div class="body" role="main">
  177. <section id="command-line-and-environment">
  178. <span id="using-on-general"></span><h1><span class="section-number">1. </span>Command line and environment<a class="headerlink" href="#command-line-and-environment" title="Link to this heading">¶</a></h1>
  179. <p>The CPython interpreter scans the command line and the environment for various
  180. settings.</p>
  181. <div class="impl-detail compound">
  182. <p><strong>CPython implementation detail:</strong> Other implementations’ command line schemes may differ. See
  183. <a class="reference internal" href="../reference/introduction.html#implementations"><span class="std std-ref">Alternate Implementations</span></a> for further resources.</p>
  184. </div>
  185. <section id="command-line">
  186. <span id="using-on-cmdline"></span><h2><span class="section-number">1.1. </span>Command line<a class="headerlink" href="#command-line" title="Link to this heading">¶</a></h2>
  187. <p>When invoking Python, you may specify any of these options:</p>
  188. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span><span class="o">[</span>-bBdEhiIOqsSuvVWx?<span class="o">]</span><span class="w"> </span><span class="o">[</span>-c<span class="w"> </span><span class="nb">command</span><span class="w"> </span><span class="p">|</span><span class="w"> </span>-m<span class="w"> </span>module-name<span class="w"> </span><span class="p">|</span><span class="w"> </span>script<span class="w"> </span><span class="p">|</span><span class="w"> </span>-<span class="w"> </span><span class="o">]</span><span class="w"> </span><span class="o">[</span>args<span class="o">]</span>
  189. </pre></div>
  190. </div>
  191. <p>The most common use case is, of course, a simple invocation of a script:</p>
  192. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span>myscript.py
  193. </pre></div>
  194. </div>
  195. <section id="interface-options">
  196. <span id="using-on-interface-options"></span><h3><span class="section-number">1.1.1. </span>Interface options<a class="headerlink" href="#interface-options" title="Link to this heading">¶</a></h3>
  197. <p>The interpreter interface resembles that of the UNIX shell, but provides some
  198. additional methods of invocation:</p>
  199. <ul class="simple">
  200. <li><p>When called with standard input connected to a tty device, it prompts for
  201. commands and executes them until an EOF (an end-of-file character, you can
  202. produce that with <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Ctrl</kbd>-<kbd class="kbd docutils literal notranslate">D</kbd></kbd> on UNIX or <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Ctrl</kbd>-<kbd class="kbd docutils literal notranslate">Z,</kbd> <kbd class="kbd docutils literal notranslate">Enter</kbd></kbd> on Windows) is read.</p></li>
  203. <li><p>When called with a file name argument or with a file as standard input, it
  204. reads and executes a script from that file.</p></li>
  205. <li><p>When called with a directory name argument, it reads and executes an
  206. appropriately named script from that directory.</p></li>
  207. <li><p>When called with <code class="docutils literal notranslate"><span class="pre">-c</span> <span class="pre">command</span></code>, it executes the Python statement(s) given as
  208. <em>command</em>. Here <em>command</em> may contain multiple statements separated by
  209. newlines. Leading whitespace is significant in Python statements!</p></li>
  210. <li><p>When called with <code class="docutils literal notranslate"><span class="pre">-m</span> <span class="pre">module-name</span></code>, the given module is located on the
  211. Python module path and executed as a script.</p></li>
  212. </ul>
  213. <p>In non-interactive mode, the entire input is parsed before it is executed.</p>
  214. <p>An interface option terminates the list of options consumed by the interpreter,
  215. all consecutive arguments will end up in <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.argv</span></code></a> – note that the first
  216. element, subscript zero (<code class="docutils literal notranslate"><span class="pre">sys.argv[0]</span></code>), is a string reflecting the program’s
  217. source.</p>
  218. <dl class="std option">
  219. <dt class="sig sig-object std" id="cmdoption-c">
  220. <span class="sig-name descname"><span class="pre">-c</span></span><span class="sig-prename descclassname"> <span class="pre">&lt;command&gt;</span></span><a class="headerlink" href="#cmdoption-c" title="Link to this definition">¶</a></dt>
  221. <dd><p>Execute the Python code in <em>command</em>. <em>command</em> can be one or more
  222. statements separated by newlines, with significant leading whitespace as in
  223. normal module code.</p>
  224. <p>If this option is given, the first element of <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.argv</span></code></a> will be
  225. <code class="docutils literal notranslate"><span class="pre">&quot;-c&quot;</span></code> and the current directory will be added to the start of
  226. <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> (allowing modules in that directory to be imported as top
  227. level modules).</p>
  228. <p class="audit-hook">Raises an <a class="reference internal" href="../library/sys.html#auditing"><span class="std std-ref">auditing event</span></a> <code class="docutils literal notranslate"><span class="pre">cpython.run_command</span></code> with argument <code class="docutils literal notranslate"><span class="pre">command</span></code>.</p>
  229. </dd></dl>
  230. <dl class="std option">
  231. <dt class="sig sig-object std" id="cmdoption-m">
  232. <span class="sig-name descname"><span class="pre">-m</span></span><span class="sig-prename descclassname"> <span class="pre">&lt;module-name&gt;</span></span><a class="headerlink" href="#cmdoption-m" title="Link to this definition">¶</a></dt>
  233. <dd><p>Search <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> for the named module and execute its contents as
  234. the <a class="reference internal" href="../library/__main__.html#module-__main__" title="__main__: The environment where top-level code is run. Covers command-line interfaces, import-time behavior, and ``__name__ == '__main__'``."><code class="xref py py-mod docutils literal notranslate"><span class="pre">__main__</span></code></a> module.</p>
  235. <p>Since the argument is a <em>module</em> name, you must not give a file extension
  236. (<code class="docutils literal notranslate"><span class="pre">.py</span></code>). The module name should be a valid absolute Python module name, but
  237. the implementation may not always enforce this (e.g. it may allow you to
  238. use a name that includes a hyphen).</p>
  239. <p>Package names (including namespace packages) are also permitted. When a
  240. package name is supplied instead
  241. of a normal module, the interpreter will execute <code class="docutils literal notranslate"><span class="pre">&lt;pkg&gt;.__main__</span></code> as
  242. the main module. This behaviour is deliberately similar to the handling
  243. of directories and zipfiles that are passed to the interpreter as the
  244. script argument.</p>
  245. <div class="admonition note">
  246. <p class="admonition-title">Note</p>
  247. <p>This option cannot be used with built-in modules and extension modules
  248. written in C, since they do not have Python module files. However, it
  249. can still be used for precompiled modules, even if the original source
  250. file is not available.</p>
  251. </div>
  252. <p>If this option is given, the first element of <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.argv</span></code></a> will be the
  253. full path to the module file (while the module file is being located, the
  254. first element will be set to <code class="docutils literal notranslate"><span class="pre">&quot;-m&quot;</span></code>). As with the <a class="reference internal" href="#cmdoption-c"><code class="xref std std-option docutils literal notranslate"><span class="pre">-c</span></code></a> option,
  255. the current directory will be added to the start of <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>.</p>
  256. <p><a class="reference internal" href="#cmdoption-I"><code class="xref std std-option docutils literal notranslate"><span class="pre">-I</span></code></a> option can be used to run the script in isolated mode where
  257. <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> contains neither the current directory nor the user’s
  258. site-packages directory. All <code class="docutils literal notranslate"><span class="pre">PYTHON*</span></code> environment variables are
  259. ignored, too.</p>
  260. <p>Many standard library modules contain code that is invoked on their execution
  261. as a script. An example is the <a class="reference internal" href="../library/timeit.html#module-timeit" title="timeit: Measure the execution time of small code snippets."><code class="xref py py-mod docutils literal notranslate"><span class="pre">timeit</span></code></a> module:</p>
  262. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span>-m<span class="w"> </span>timeit<span class="w"> </span>-s<span class="w"> </span><span class="s2">&quot;setup here&quot;</span><span class="w"> </span><span class="s2">&quot;benchmarked code here&quot;</span>
  263. python<span class="w"> </span>-m<span class="w"> </span>timeit<span class="w"> </span>-h<span class="w"> </span><span class="c1"># for details</span>
  264. </pre></div>
  265. </div>
  266. <p class="audit-hook">Raises an <a class="reference internal" href="../library/sys.html#auditing"><span class="std std-ref">auditing event</span></a> <code class="docutils literal notranslate"><span class="pre">cpython.run_module</span></code> with argument <code class="docutils literal notranslate"><span class="pre">module-name</span></code>.</p>
  267. <div class="admonition seealso">
  268. <p class="admonition-title">See also</p>
  269. <dl class="simple">
  270. <dt><a class="reference internal" href="../library/runpy.html#runpy.run_module" title="runpy.run_module"><code class="xref py py-func docutils literal notranslate"><span class="pre">runpy.run_module()</span></code></a></dt><dd><p>Equivalent functionality directly available to Python code</p>
  271. </dd>
  272. </dl>
  273. <p><span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-0338/"><strong>PEP 338</strong></a> – Executing modules as scripts</p>
  274. </div>
  275. <div class="versionchanged">
  276. <p><span class="versionmodified changed">Changed in version 3.1: </span>Supply the package name to run a <code class="docutils literal notranslate"><span class="pre">__main__</span></code> submodule.</p>
  277. </div>
  278. <div class="versionchanged">
  279. <p><span class="versionmodified changed">Changed in version 3.4: </span>namespace packages are also supported</p>
  280. </div>
  281. </dd></dl>
  282. <dl class="describe" id="cmdarg-dash">
  283. <dt class="sig sig-object">
  284. <span class="sig-name descname"><span class="pre">-</span></span></dt>
  285. <dd><p>Read commands from standard input (<a class="reference internal" href="../library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdin</span></code></a>). If standard input is
  286. a terminal, <a class="reference internal" href="#cmdoption-i"><code class="xref std std-option docutils literal notranslate"><span class="pre">-i</span></code></a> is implied.</p>
  287. <p>If this option is given, the first element of <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.argv</span></code></a> will be
  288. <code class="docutils literal notranslate"><span class="pre">&quot;-&quot;</span></code> and the current directory will be added to the start of
  289. <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>.</p>
  290. <p class="audit-hook" id="audit_event_cpython_run_stdin_0">Raises an <a class="reference internal" href="../library/sys.html#auditing"><span class="std std-ref">auditing event</span></a> <code class="docutils literal notranslate"><span class="pre">cpython.run_stdin</span></code> with no arguments.</p>
  291. </dd></dl>
  292. <dl class="describe" id="cmdarg-script">
  293. <dt class="sig sig-object">
  294. <span class="sig-name descname"><span class="pre">&lt;script&gt;</span></span></dt>
  295. <dd><p>Execute the Python code contained in <em>script</em>, which must be a filesystem
  296. path (absolute or relative) referring to either a Python file, a directory
  297. containing a <code class="docutils literal notranslate"><span class="pre">__main__.py</span></code> file, or a zipfile containing a
  298. <code class="docutils literal notranslate"><span class="pre">__main__.py</span></code> file.</p>
  299. <p>If this option is given, the first element of <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.argv</span></code></a> will be the
  300. script name as given on the command line.</p>
  301. <p>If the script name refers directly to a Python file, the directory
  302. containing that file is added to the start of <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>, and the
  303. file is executed as the <a class="reference internal" href="../library/__main__.html#module-__main__" title="__main__: The environment where top-level code is run. Covers command-line interfaces, import-time behavior, and ``__name__ == '__main__'``."><code class="xref py py-mod docutils literal notranslate"><span class="pre">__main__</span></code></a> module.</p>
  304. <p>If the script name refers to a directory or zipfile, the script name is
  305. added to the start of <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> and the <code class="docutils literal notranslate"><span class="pre">__main__.py</span></code> file in
  306. that location is executed as the <a class="reference internal" href="../library/__main__.html#module-__main__" title="__main__: The environment where top-level code is run. Covers command-line interfaces, import-time behavior, and ``__name__ == '__main__'``."><code class="xref py py-mod docutils literal notranslate"><span class="pre">__main__</span></code></a> module.</p>
  307. <p><a class="reference internal" href="#cmdoption-I"><code class="xref std std-option docutils literal notranslate"><span class="pre">-I</span></code></a> option can be used to run the script in isolated mode where
  308. <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> contains neither the script’s directory nor the user’s
  309. site-packages directory. All <code class="docutils literal notranslate"><span class="pre">PYTHON*</span></code> environment variables are
  310. ignored, too.</p>
  311. <p class="audit-hook" id="audit_event_cpython_run_file_0">Raises an <a class="reference internal" href="../library/sys.html#auditing"><span class="std std-ref">auditing event</span></a> <code class="docutils literal notranslate"><span class="pre">cpython.run_file</span></code> with argument <code class="docutils literal notranslate"><span class="pre">filename</span></code>.</p>
  312. <div class="admonition seealso">
  313. <p class="admonition-title">See also</p>
  314. <dl class="simple">
  315. <dt><a class="reference internal" href="../library/runpy.html#runpy.run_path" title="runpy.run_path"><code class="xref py py-func docutils literal notranslate"><span class="pre">runpy.run_path()</span></code></a></dt><dd><p>Equivalent functionality directly available to Python code</p>
  316. </dd>
  317. </dl>
  318. </div>
  319. </dd></dl>
  320. <p>If no interface option is given, <a class="reference internal" href="#cmdoption-i"><code class="xref std std-option docutils literal notranslate"><span class="pre">-i</span></code></a> is implied, <code class="docutils literal notranslate"><span class="pre">sys.argv[0]</span></code> is
  321. an empty string (<code class="docutils literal notranslate"><span class="pre">&quot;&quot;</span></code>) and the current directory will be added to the
  322. start of <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>. Also, tab-completion and history editing is
  323. automatically enabled, if available on your platform (see
  324. <a class="reference internal" href="../library/site.html#rlcompleter-config"><span class="std std-ref">Readline configuration</span></a>).</p>
  325. <div class="admonition seealso">
  326. <p class="admonition-title">See also</p>
  327. <p><a class="reference internal" href="../tutorial/interpreter.html#tut-invoking"><span class="std std-ref">Invoking the Interpreter</span></a></p>
  328. </div>
  329. <div class="versionchanged">
  330. <p><span class="versionmodified changed">Changed in version 3.4: </span>Automatic enabling of tab-completion and history editing.</p>
  331. </div>
  332. </section>
  333. <section id="generic-options">
  334. <span id="using-on-generic-options"></span><h3><span class="section-number">1.1.2. </span>Generic options<a class="headerlink" href="#generic-options" title="Link to this heading">¶</a></h3>
  335. <dl class="std option">
  336. <dt class="sig sig-object std" id="cmdoption-0">
  337. <span class="sig-name descname"><span class="pre">-?</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-0" title="Link to this definition">¶</a></dt>
  338. <dt class="sig sig-object std" id="cmdoption-h">
  339. <span class="sig-name descname"><span class="pre">-h</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-h" title="Link to this definition">¶</a></dt>
  340. <dt class="sig sig-object std" id="cmdoption-help">
  341. <span class="sig-name descname"><span class="pre">--help</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-help" title="Link to this definition">¶</a></dt>
  342. <dd><p>Print a short description of all command line options and corresponding
  343. environment variables and exit.</p>
  344. </dd></dl>
  345. <dl class="std option">
  346. <dt class="sig sig-object std" id="cmdoption-help-env">
  347. <span class="sig-name descname"><span class="pre">--help-env</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-help-env" title="Link to this definition">¶</a></dt>
  348. <dd><p>Print a short description of Python-specific environment variables
  349. and exit.</p>
  350. <div class="versionadded">
  351. <p><span class="versionmodified added">New in version 3.11.</span></p>
  352. </div>
  353. </dd></dl>
  354. <dl class="std option">
  355. <dt class="sig sig-object std" id="cmdoption-help-xoptions">
  356. <span class="sig-name descname"><span class="pre">--help-xoptions</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-help-xoptions" title="Link to this definition">¶</a></dt>
  357. <dd><p>Print a description of implementation-specific <a class="reference internal" href="#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> options
  358. and exit.</p>
  359. <div class="versionadded">
  360. <p><span class="versionmodified added">New in version 3.11.</span></p>
  361. </div>
  362. </dd></dl>
  363. <dl class="std option">
  364. <dt class="sig sig-object std" id="cmdoption-help-all">
  365. <span class="sig-name descname"><span class="pre">--help-all</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-help-all" title="Link to this definition">¶</a></dt>
  366. <dd><p>Print complete usage information and exit.</p>
  367. <div class="versionadded">
  368. <p><span class="versionmodified added">New in version 3.11.</span></p>
  369. </div>
  370. </dd></dl>
  371. <dl class="std option">
  372. <dt class="sig sig-object std" id="cmdoption-V">
  373. <span class="sig-name descname"><span class="pre">-V</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-V" title="Link to this definition">¶</a></dt>
  374. <dt class="sig sig-object std" id="cmdoption-version">
  375. <span class="sig-name descname"><span class="pre">--version</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-version" title="Link to this definition">¶</a></dt>
  376. <dd><p>Print the Python version number and exit. Example output could be:</p>
  377. <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Python 3.8.0b2+
  378. </pre></div>
  379. </div>
  380. <p>When given twice, print more information about the build, like:</p>
  381. <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Python 3.8.0b2+ (3.8:0c076caaa8, Apr 20 2019, 21:55:00)
  382. [GCC 6.2.0 20161005]
  383. </pre></div>
  384. </div>
  385. <div class="versionadded">
  386. <p><span class="versionmodified added">New in version 3.6: </span>The <code class="docutils literal notranslate"><span class="pre">-VV</span></code> option.</p>
  387. </div>
  388. </dd></dl>
  389. </section>
  390. <section id="miscellaneous-options">
  391. <span id="using-on-misc-options"></span><h3><span class="section-number">1.1.3. </span>Miscellaneous options<a class="headerlink" href="#miscellaneous-options" title="Link to this heading">¶</a></h3>
  392. <dl class="std option">
  393. <dt class="sig sig-object std" id="cmdoption-b">
  394. <span class="sig-name descname"><span class="pre">-b</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-b" title="Link to this definition">¶</a></dt>
  395. <dd><p>Issue a warning when converting <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> or <a class="reference internal" href="../library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a> to
  396. <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> without specifying encoding or comparing <code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code> or
  397. <code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code> with <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code> or <code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code> with <a class="reference internal" href="../library/functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>.
  398. Issue an error when the option is given twice (<code class="xref std std-option docutils literal notranslate"><span class="pre">-bb</span></code>).</p>
  399. <div class="versionchanged">
  400. <p><span class="versionmodified changed">Changed in version 3.5: </span>Affects also comparisons of <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> with <a class="reference internal" href="../library/functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>.</p>
  401. </div>
  402. </dd></dl>
  403. <dl class="std option">
  404. <dt class="sig sig-object std" id="cmdoption-B">
  405. <span class="sig-name descname"><span class="pre">-B</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-B" title="Link to this definition">¶</a></dt>
  406. <dd><p>If given, Python won’t try to write <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files on the
  407. import of source modules. See also <span class="target" id="index-1"></span><a class="reference internal" href="#envvar-PYTHONDONTWRITEBYTECODE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONDONTWRITEBYTECODE</span></code></a>.</p>
  408. </dd></dl>
  409. <dl class="std option">
  410. <dt class="sig sig-object std" id="cmdoption-check-hash-based-pycs">
  411. <span class="sig-name descname"><span class="pre">--check-hash-based-pycs</span></span><span class="sig-prename descclassname"> <span class="pre">default|always|never</span></span><a class="headerlink" href="#cmdoption-check-hash-based-pycs" title="Link to this definition">¶</a></dt>
  412. <dd><p>Control the validation behavior of hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files. See
  413. <a class="reference internal" href="../reference/import.html#pyc-invalidation"><span class="std std-ref">Cached bytecode invalidation</span></a>. When set to <code class="docutils literal notranslate"><span class="pre">default</span></code>, checked and unchecked
  414. hash-based bytecode cache files are validated according to their default
  415. semantics. When set to <code class="docutils literal notranslate"><span class="pre">always</span></code>, all hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files, whether
  416. checked or unchecked, are validated against their corresponding source
  417. file. When set to <code class="docutils literal notranslate"><span class="pre">never</span></code>, hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files are not validated
  418. against their corresponding source files.</p>
  419. <p>The semantics of timestamp-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files are unaffected by this
  420. option.</p>
  421. </dd></dl>
  422. <dl class="std option">
  423. <dt class="sig sig-object std" id="cmdoption-d">
  424. <span class="sig-name descname"><span class="pre">-d</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-d" title="Link to this definition">¶</a></dt>
  425. <dd><p>Turn on parser debugging output (for expert only).
  426. See also the <span class="target" id="index-2"></span><a class="reference internal" href="#envvar-PYTHONDEBUG"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONDEBUG</span></code></a> environment variable.</p>
  427. <p>This option requires a <a class="reference internal" href="configure.html#debug-build"><span class="std std-ref">debug build of Python</span></a>, otherwise
  428. it’s ignored.</p>
  429. </dd></dl>
  430. <dl class="std option">
  431. <dt class="sig sig-object std" id="cmdoption-E">
  432. <span class="sig-name descname"><span class="pre">-E</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-E" title="Link to this definition">¶</a></dt>
  433. <dd><p>Ignore all <code class="docutils literal notranslate"><span class="pre">PYTHON*</span></code> environment variables, e.g.
  434. <span class="target" id="index-3"></span><a class="reference internal" href="#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPATH</span></code></a> and <span class="target" id="index-4"></span><a class="reference internal" href="#envvar-PYTHONHOME"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHOME</span></code></a>, that might be set.</p>
  435. <p>See also the <a class="reference internal" href="#cmdoption-P"><code class="xref std std-option docutils literal notranslate"><span class="pre">-P</span></code></a> and <a class="reference internal" href="#cmdoption-I"><code class="xref std std-option docutils literal notranslate"><span class="pre">-I</span></code></a> (isolated) options.</p>
  436. </dd></dl>
  437. <dl class="std option">
  438. <dt class="sig sig-object std" id="cmdoption-i">
  439. <span class="sig-name descname"><span class="pre">-i</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-i" title="Link to this definition">¶</a></dt>
  440. <dd><p>When a script is passed as first argument or the <a class="reference internal" href="#cmdoption-c"><code class="xref std std-option docutils literal notranslate"><span class="pre">-c</span></code></a> option is used,
  441. enter interactive mode after executing the script or the command, even when
  442. <a class="reference internal" href="../library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdin</span></code></a> does not appear to be a terminal. The
  443. <span class="target" id="index-5"></span><a class="reference internal" href="#envvar-PYTHONSTARTUP"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONSTARTUP</span></code></a> file is not read.</p>
  444. <p>This can be useful to inspect global variables or a stack trace when a script
  445. raises an exception. See also <span class="target" id="index-6"></span><a class="reference internal" href="#envvar-PYTHONINSPECT"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONINSPECT</span></code></a>.</p>
  446. </dd></dl>
  447. <dl class="std option">
  448. <dt class="sig sig-object std" id="cmdoption-I">
  449. <span class="sig-name descname"><span class="pre">-I</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-I" title="Link to this definition">¶</a></dt>
  450. <dd><p>Run Python in isolated mode. This also implies <a class="reference internal" href="#cmdoption-E"><code class="xref std std-option docutils literal notranslate"><span class="pre">-E</span></code></a>, <a class="reference internal" href="#cmdoption-P"><code class="xref std std-option docutils literal notranslate"><span class="pre">-P</span></code></a>
  451. and <a class="reference internal" href="#cmdoption-s"><code class="xref std std-option docutils literal notranslate"><span class="pre">-s</span></code></a> options.</p>
  452. <p>In isolated mode <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> contains neither the script’s directory nor
  453. the user’s site-packages directory. All <code class="docutils literal notranslate"><span class="pre">PYTHON*</span></code> environment
  454. variables are ignored, too. Further restrictions may be imposed to prevent
  455. the user from injecting malicious code.</p>
  456. <div class="versionadded">
  457. <p><span class="versionmodified added">New in version 3.4.</span></p>
  458. </div>
  459. </dd></dl>
  460. <dl class="std option">
  461. <dt class="sig sig-object std" id="cmdoption-O">
  462. <span class="sig-name descname"><span class="pre">-O</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-O" title="Link to this definition">¶</a></dt>
  463. <dd><p>Remove assert statements and any code conditional on the value of
  464. <a class="reference internal" href="../library/constants.html#debug__" title="__debug__"><code class="xref py py-const docutils literal notranslate"><span class="pre">__debug__</span></code></a>. Augment the filename for compiled
  465. (<a class="reference internal" href="../glossary.html#term-bytecode"><span class="xref std std-term">bytecode</span></a>) files by adding <code class="docutils literal notranslate"><span class="pre">.opt-1</span></code> before the <code class="docutils literal notranslate"><span class="pre">.pyc</span></code>
  466. extension (see <span class="target" id="index-7"></span><a class="pep reference external" href="https://peps.python.org/pep-0488/"><strong>PEP 488</strong></a>). See also <span class="target" id="index-8"></span><a class="reference internal" href="#envvar-PYTHONOPTIMIZE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONOPTIMIZE</span></code></a>.</p>
  467. <div class="versionchanged">
  468. <p><span class="versionmodified changed">Changed in version 3.5: </span>Modify <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> filenames according to <span class="target" id="index-9"></span><a class="pep reference external" href="https://peps.python.org/pep-0488/"><strong>PEP 488</strong></a>.</p>
  469. </div>
  470. </dd></dl>
  471. <dl class="std option">
  472. <dt class="sig sig-object std" id="cmdoption-OO">
  473. <span class="sig-name descname"><span class="pre">-OO</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-OO" title="Link to this definition">¶</a></dt>
  474. <dd><p>Do <a class="reference internal" href="#cmdoption-O"><code class="xref std std-option docutils literal notranslate"><span class="pre">-O</span></code></a> and also discard docstrings. Augment the filename
  475. for compiled (<a class="reference internal" href="../glossary.html#term-bytecode"><span class="xref std std-term">bytecode</span></a>) files by adding <code class="docutils literal notranslate"><span class="pre">.opt-2</span></code> before the
  476. <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> extension (see <span class="target" id="index-10"></span><a class="pep reference external" href="https://peps.python.org/pep-0488/"><strong>PEP 488</strong></a>).</p>
  477. <div class="versionchanged">
  478. <p><span class="versionmodified changed">Changed in version 3.5: </span>Modify <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> filenames according to <span class="target" id="index-11"></span><a class="pep reference external" href="https://peps.python.org/pep-0488/"><strong>PEP 488</strong></a>.</p>
  479. </div>
  480. </dd></dl>
  481. <dl class="std option">
  482. <dt class="sig sig-object std" id="cmdoption-P">
  483. <span class="sig-name descname"><span class="pre">-P</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-P" title="Link to this definition">¶</a></dt>
  484. <dd><p>Don’t prepend a potentially unsafe path to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>:</p>
  485. <ul class="simple">
  486. <li><p><code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">module</span></code> command line: Don’t prepend the current working
  487. directory.</p></li>
  488. <li><p><code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">script.py</span></code> command line: Don’t prepend the script’s directory.
  489. If it’s a symbolic link, resolve symbolic links.</p></li>
  490. <li><p><code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-c</span> <span class="pre">code</span></code> and <code class="docutils literal notranslate"><span class="pre">python</span></code> (REPL) command lines: Don’t prepend an
  491. empty string, which means the current working directory.</p></li>
  492. </ul>
  493. <p>See also the <span class="target" id="index-12"></span><a class="reference internal" href="#envvar-PYTHONSAFEPATH"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONSAFEPATH</span></code></a> environment variable, and <a class="reference internal" href="#cmdoption-E"><code class="xref std std-option docutils literal notranslate"><span class="pre">-E</span></code></a>
  494. and <a class="reference internal" href="#cmdoption-I"><code class="xref std std-option docutils literal notranslate"><span class="pre">-I</span></code></a> (isolated) options.</p>
  495. <div class="versionadded">
  496. <p><span class="versionmodified added">New in version 3.11.</span></p>
  497. </div>
  498. </dd></dl>
  499. <dl class="std option">
  500. <dt class="sig sig-object std" id="cmdoption-q">
  501. <span class="sig-name descname"><span class="pre">-q</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-q" title="Link to this definition">¶</a></dt>
  502. <dd><p>Don’t display the copyright and version messages even in interactive mode.</p>
  503. <div class="versionadded">
  504. <p><span class="versionmodified added">New in version 3.2.</span></p>
  505. </div>
  506. </dd></dl>
  507. <dl class="std option">
  508. <dt class="sig sig-object std" id="cmdoption-R">
  509. <span class="sig-name descname"><span class="pre">-R</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-R" title="Link to this definition">¶</a></dt>
  510. <dd><p>Turn on hash randomization. This option only has an effect if the
  511. <span class="target" id="index-13"></span><a class="reference internal" href="#envvar-PYTHONHASHSEED"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHASHSEED</span></code></a> environment variable is set to <code class="docutils literal notranslate"><span class="pre">0</span></code>, since hash
  512. randomization is enabled by default.</p>
  513. <p>On previous versions of Python, this option turns on hash randomization,
  514. so that the <a class="reference internal" href="../reference/datamodel.html#object.__hash__" title="object.__hash__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__hash__()</span></code></a> values of str and bytes objects
  515. are “salted” with an unpredictable random value. Although they remain
  516. constant within an individual Python process, they are not predictable
  517. between repeated invocations of Python.</p>
  518. <p>Hash randomization is intended to provide protection against a
  519. denial-of-service caused by carefully chosen inputs that exploit the worst
  520. case performance of a dict construction, <em>O</em>(<em>n</em><sup>2</sup>) complexity. See
  521. <a class="reference external" href="http://ocert.org/advisories/ocert-2011-003.html">http://ocert.org/advisories/ocert-2011-003.html</a> for details.</p>
  522. <p><span class="target" id="index-14"></span><a class="reference internal" href="#envvar-PYTHONHASHSEED"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHASHSEED</span></code></a> allows you to set a fixed value for the hash
  523. seed secret.</p>
  524. <div class="versionadded">
  525. <p><span class="versionmodified added">New in version 3.2.3.</span></p>
  526. </div>
  527. <div class="versionchanged">
  528. <p><span class="versionmodified changed">Changed in version 3.7: </span>The option is no longer ignored.</p>
  529. </div>
  530. </dd></dl>
  531. <dl class="std option">
  532. <dt class="sig sig-object std" id="cmdoption-s">
  533. <span class="sig-name descname"><span class="pre">-s</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-s" title="Link to this definition">¶</a></dt>
  534. <dd><p>Don’t add the <a class="reference internal" href="../library/site.html#site.USER_SITE" title="site.USER_SITE"><code class="xref py py-data docutils literal notranslate"><span class="pre">user</span> <span class="pre">site-packages</span> <span class="pre">directory</span></code></a> to
  535. <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>.</p>
  536. <p>See also <span class="target" id="index-15"></span><a class="reference internal" href="#envvar-PYTHONNOUSERSITE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONNOUSERSITE</span></code></a>.</p>
  537. <div class="admonition seealso">
  538. <p class="admonition-title">See also</p>
  539. <p><span class="target" id="index-16"></span><a class="pep reference external" href="https://peps.python.org/pep-0370/"><strong>PEP 370</strong></a> – Per user site-packages directory</p>
  540. </div>
  541. </dd></dl>
  542. <dl class="std option">
  543. <dt class="sig sig-object std" id="cmdoption-S">
  544. <span class="sig-name descname"><span class="pre">-S</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-S" title="Link to this definition">¶</a></dt>
  545. <dd><p>Disable the import of the module <a class="reference internal" href="../library/site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a> and the site-dependent
  546. manipulations of <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> that it entails. Also disable these
  547. manipulations if <a class="reference internal" href="../library/site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a> is explicitly imported later (call
  548. <a class="reference internal" href="../library/site.html#site.main" title="site.main"><code class="xref py py-func docutils literal notranslate"><span class="pre">site.main()</span></code></a> if you want them to be triggered).</p>
  549. </dd></dl>
  550. <dl class="std option">
  551. <dt class="sig sig-object std" id="cmdoption-u">
  552. <span class="sig-name descname"><span class="pre">-u</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-u" title="Link to this definition">¶</a></dt>
  553. <dd><p>Force the stdout and stderr streams to be unbuffered. This option has no
  554. effect on the stdin stream.</p>
  555. <p>See also <span class="target" id="index-17"></span><a class="reference internal" href="#envvar-PYTHONUNBUFFERED"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONUNBUFFERED</span></code></a>.</p>
  556. <div class="versionchanged">
  557. <p><span class="versionmodified changed">Changed in version 3.7: </span>The text layer of the stdout and stderr streams now is unbuffered.</p>
  558. </div>
  559. </dd></dl>
  560. <dl class="std option">
  561. <dt class="sig sig-object std" id="cmdoption-v">
  562. <span class="sig-name descname"><span class="pre">-v</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-v" title="Link to this definition">¶</a></dt>
  563. <dd><p>Print a message each time a module is initialized, showing the place
  564. (filename or built-in module) from which it is loaded. When given twice
  565. (<code class="xref std std-option docutils literal notranslate"><span class="pre">-vv</span></code>), print a message for each file that is checked for when
  566. searching for a module. Also provides information on module cleanup at exit.</p>
  567. <div class="versionchanged">
  568. <p><span class="versionmodified changed">Changed in version 3.10: </span>The <a class="reference internal" href="../library/site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a> module reports the site-specific paths
  569. and <code class="file docutils literal notranslate"><span class="pre">.pth</span></code> files being processed.</p>
  570. </div>
  571. <p>See also <span class="target" id="index-18"></span><a class="reference internal" href="#envvar-PYTHONVERBOSE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONVERBOSE</span></code></a>.</p>
  572. </dd></dl>
  573. <dl class="std option" id="using-on-warnings">
  574. <dt class="sig sig-object std" id="cmdoption-W">
  575. <span class="sig-name descname"><span class="pre">-W</span></span><span class="sig-prename descclassname"> <span class="pre">arg</span></span><a class="headerlink" href="#cmdoption-W" title="Link to this definition">¶</a></dt>
  576. <dd><p>Warning control. Python’s warning machinery by default prints warning
  577. messages to <a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stderr</span></code></a>.</p>
  578. <p>The simplest settings apply a particular action unconditionally to all
  579. warnings emitted by a process (even those that are otherwise ignored by
  580. default):</p>
  581. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>-Wdefault<span class="w"> </span><span class="c1"># Warn once per call location</span>
  582. -Werror<span class="w"> </span><span class="c1"># Convert to exceptions</span>
  583. -Walways<span class="w"> </span><span class="c1"># Warn every time</span>
  584. -Wmodule<span class="w"> </span><span class="c1"># Warn once per calling module</span>
  585. -Wonce<span class="w"> </span><span class="c1"># Warn once per Python process</span>
  586. -Wignore<span class="w"> </span><span class="c1"># Never warn</span>
  587. </pre></div>
  588. </div>
  589. <p>The action names can be abbreviated as desired and the interpreter will
  590. resolve them to the appropriate action name. For example, <code class="docutils literal notranslate"><span class="pre">-Wi</span></code> is the
  591. same as <code class="docutils literal notranslate"><span class="pre">-Wignore</span></code>.</p>
  592. <p>The full form of argument is:</p>
  593. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>action:message:category:module:lineno
  594. </pre></div>
  595. </div>
  596. <p>Empty fields match all values; trailing empty fields may be omitted. For
  597. example <code class="docutils literal notranslate"><span class="pre">-W</span> <span class="pre">ignore::DeprecationWarning</span></code> ignores all DeprecationWarning
  598. warnings.</p>
  599. <p>The <em>action</em> field is as explained above but only applies to warnings that
  600. match the remaining fields.</p>
  601. <p>The <em>message</em> field must match the whole warning message; this match is
  602. case-insensitive.</p>
  603. <p>The <em>category</em> field matches the warning category
  604. (ex: <code class="docutils literal notranslate"><span class="pre">DeprecationWarning</span></code>). This must be a class name; the match test
  605. whether the actual warning category of the message is a subclass of the
  606. specified warning category.</p>
  607. <p>The <em>module</em> field matches the (fully qualified) module name; this match is
  608. case-sensitive.</p>
  609. <p>The <em>lineno</em> field matches the line number, where zero matches all line
  610. numbers and is thus equivalent to an omitted line number.</p>
  611. <p>Multiple <a class="reference internal" href="#cmdoption-W"><code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code></a> options can be given; when a warning matches more than
  612. one option, the action for the last matching option is performed. Invalid
  613. <a class="reference internal" href="#cmdoption-W"><code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code></a> options are ignored (though, a warning message is printed about
  614. invalid options when the first warning is issued).</p>
  615. <p>Warnings can also be controlled using the <span class="target" id="index-19"></span><a class="reference internal" href="#envvar-PYTHONWARNINGS"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONWARNINGS</span></code></a>
  616. environment variable and from within a Python program using the
  617. <a class="reference internal" href="../library/warnings.html#module-warnings" title="warnings: Issue warning messages and control their disposition."><code class="xref py py-mod docutils literal notranslate"><span class="pre">warnings</span></code></a> module. For example, the <a class="reference internal" href="../library/warnings.html#warnings.filterwarnings" title="warnings.filterwarnings"><code class="xref py py-func docutils literal notranslate"><span class="pre">warnings.filterwarnings()</span></code></a>
  618. function can be used to use a regular expression on the warning message.</p>
  619. <p>See <a class="reference internal" href="../library/warnings.html#warning-filter"><span class="std std-ref">The Warnings Filter</span></a> and <a class="reference internal" href="../library/warnings.html#describing-warning-filters"><span class="std std-ref">Describing Warning Filters</span></a> for more
  620. details.</p>
  621. </dd></dl>
  622. <dl class="std option">
  623. <dt class="sig sig-object std" id="cmdoption-x">
  624. <span class="sig-name descname"><span class="pre">-x</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-x" title="Link to this definition">¶</a></dt>
  625. <dd><p>Skip the first line of the source, allowing use of non-Unix forms of
  626. <code class="docutils literal notranslate"><span class="pre">#!cmd</span></code>. This is intended for a DOS specific hack only.</p>
  627. </dd></dl>
  628. <dl class="std option">
  629. <dt class="sig sig-object std" id="cmdoption-X">
  630. <span class="sig-name descname"><span class="pre">-X</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-X" title="Link to this definition">¶</a></dt>
  631. <dd><p>Reserved for various implementation-specific options. CPython currently
  632. defines the following possible values:</p>
  633. <ul class="simple">
  634. <li><p><code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">faulthandler</span></code> to enable <a class="reference internal" href="../library/faulthandler.html#module-faulthandler" title="faulthandler: Dump the Python traceback."><code class="xref py py-mod docutils literal notranslate"><span class="pre">faulthandler</span></code></a>.
  635. See also <span class="target" id="index-20"></span><a class="reference internal" href="#envvar-PYTHONFAULTHANDLER"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONFAULTHANDLER</span></code></a>.</p></li>
  636. <li><p><code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">showrefcount</span></code> to output the total reference count and number of used
  637. memory blocks when the program finishes or after each statement in the
  638. interactive interpreter. This only works on <a class="reference internal" href="configure.html#debug-build"><span class="std std-ref">debug builds</span></a>.</p></li>
  639. <li><p><code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">tracemalloc</span></code> to start tracing Python memory allocations using the
  640. <a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tracemalloc</span></code></a> module. By default, only the most recent frame is
  641. stored in a traceback of a trace. Use <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">tracemalloc=NFRAME</span></code> to start
  642. tracing with a traceback limit of <em>NFRAME</em> frames.
  643. See <a class="reference internal" href="../library/tracemalloc.html#tracemalloc.start" title="tracemalloc.start"><code class="xref py py-func docutils literal notranslate"><span class="pre">tracemalloc.start()</span></code></a> and <span class="target" id="index-21"></span><a class="reference internal" href="#envvar-PYTHONTRACEMALLOC"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONTRACEMALLOC</span></code></a>
  644. for more information.</p></li>
  645. <li><p><code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">int_max_str_digits</span></code> configures the <a class="reference internal" href="../library/stdtypes.html#int-max-str-digits"><span class="std std-ref">integer string conversion
  646. length limitation</span></a>. See also
  647. <span class="target" id="index-22"></span><a class="reference internal" href="#envvar-PYTHONINTMAXSTRDIGITS"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONINTMAXSTRDIGITS</span></code></a>.</p></li>
  648. <li><p><code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">importtime</span></code> to show how long each import takes. It shows module
  649. name, cumulative time (including nested imports) and self time (excluding
  650. nested imports). Note that its output may be broken in multi-threaded
  651. application. Typical usage is <code class="docutils literal notranslate"><span class="pre">python3</span> <span class="pre">-X</span> <span class="pre">importtime</span> <span class="pre">-c</span> <span class="pre">'import</span>
  652. <span class="pre">asyncio'</span></code>. See also <span class="target" id="index-23"></span><a class="reference internal" href="#envvar-PYTHONPROFILEIMPORTTIME"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPROFILEIMPORTTIME</span></code></a>.</p></li>
  653. <li><p><code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">dev</span></code>: enable <a class="reference internal" href="../library/devmode.html#devmode"><span class="std std-ref">Python Development Mode</span></a>, introducing
  654. additional runtime checks that are too expensive to be enabled by
  655. default. See also <span class="target" id="index-24"></span><a class="reference internal" href="#envvar-PYTHONDEVMODE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONDEVMODE</span></code></a>.</p></li>
  656. <li><p><code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">utf8</span></code> enables the <a class="reference internal" href="../library/os.html#utf8-mode"><span class="std std-ref">Python UTF-8 Mode</span></a>.
  657. <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">utf8=0</span></code> explicitly disables <a class="reference internal" href="../library/os.html#utf8-mode"><span class="std std-ref">Python UTF-8 Mode</span></a>
  658. (even when it would otherwise activate automatically).
  659. See also <span class="target" id="index-25"></span><a class="reference internal" href="#envvar-PYTHONUTF8"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONUTF8</span></code></a>.</p></li>
  660. <li><p><code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">pycache_prefix=PATH</span></code> enables writing <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files to a parallel
  661. tree rooted at the given directory instead of to the code tree. See also
  662. <span class="target" id="index-26"></span><a class="reference internal" href="#envvar-PYTHONPYCACHEPREFIX"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPYCACHEPREFIX</span></code></a>.</p></li>
  663. <li><p><code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">warn_default_encoding</span></code> issues a <a class="reference internal" href="../library/exceptions.html#EncodingWarning" title="EncodingWarning"><code class="xref py py-class docutils literal notranslate"><span class="pre">EncodingWarning</span></code></a> when the
  664. locale-specific default encoding is used for opening files.
  665. See also <span class="target" id="index-27"></span><a class="reference internal" href="#envvar-PYTHONWARNDEFAULTENCODING"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONWARNDEFAULTENCODING</span></code></a>.</p></li>
  666. <li><p><code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">no_debug_ranges</span></code> disables the inclusion of the tables mapping extra
  667. location information (end line, start column offset and end column offset)
  668. to every instruction in code objects. This is useful when smaller code
  669. objects and pyc files are desired as well as suppressing the extra visual
  670. location indicators when the interpreter displays tracebacks. See also
  671. <span class="target" id="index-28"></span><a class="reference internal" href="#envvar-PYTHONNODEBUGRANGES"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONNODEBUGRANGES</span></code></a>.</p></li>
  672. <li><p><code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">frozen_modules</span></code> determines whether or not frozen modules are
  673. ignored by the import machinery. A value of “on” means they get
  674. imported and “off” means they are ignored. The default is “on”
  675. if this is an installed Python (the normal case). If it’s under
  676. development (running from the source tree) then the default is “off”.
  677. Note that the “importlib_bootstrap” and “importlib_bootstrap_external”
  678. frozen modules are always used, even if this flag is set to “off”.</p></li>
  679. <li><p><code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">perf</span></code> enables support for the Linux <code class="docutils literal notranslate"><span class="pre">perf</span></code> profiler.
  680. When this option is provided, the <code class="docutils literal notranslate"><span class="pre">perf</span></code> profiler will be able to
  681. report Python calls. This option is only available on some platforms and
  682. will do nothing if is not supported on the current system. The default value
  683. is “off”. See also <span class="target" id="index-29"></span><a class="reference internal" href="#envvar-PYTHONPERFSUPPORT"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPERFSUPPORT</span></code></a> and <a class="reference internal" href="../howto/perf_profiling.html#perf-profiling"><span class="std std-ref">Python support for the Linux perf profiler</span></a>.</p></li>
  684. </ul>
  685. <p>It also allows passing arbitrary values and retrieving them through the
  686. <a class="reference internal" href="../library/sys.html#sys._xoptions" title="sys._xoptions"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys._xoptions</span></code></a> dictionary.</p>
  687. <div class="versionadded">
  688. <p><span class="versionmodified added">New in version 3.2.</span></p>
  689. </div>
  690. <div class="versionchanged">
  691. <p><span class="versionmodified changed">Changed in version 3.3: </span>Added the <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">faulthandler</span></code> option.</p>
  692. </div>
  693. <div class="versionchanged">
  694. <p><span class="versionmodified changed">Changed in version 3.4: </span>Added the <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">showrefcount</span></code> and <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">tracemalloc</span></code> options.</p>
  695. </div>
  696. <div class="versionchanged">
  697. <p><span class="versionmodified changed">Changed in version 3.6: </span>Added the <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">showalloccount</span></code> option.</p>
  698. </div>
  699. <div class="versionchanged">
  700. <p><span class="versionmodified changed">Changed in version 3.7: </span>Added the <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">importtime</span></code>, <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">dev</span></code> and <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">utf8</span></code> options.</p>
  701. </div>
  702. <div class="versionchanged">
  703. <p><span class="versionmodified changed">Changed in version 3.8: </span>Added the <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">pycache_prefix</span></code> option. The <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">dev</span></code> option now logs
  704. <code class="docutils literal notranslate"><span class="pre">close()</span></code> exceptions in <a class="reference internal" href="../library/io.html#io.IOBase" title="io.IOBase"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.IOBase</span></code></a> destructor.</p>
  705. </div>
  706. <div class="versionchanged">
  707. <p><span class="versionmodified changed">Changed in version 3.9: </span>Using <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">dev</span></code> option, check <em>encoding</em> and <em>errors</em> arguments on
  708. string encoding and decoding operations.</p>
  709. <p>The <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">showalloccount</span></code> option has been removed.</p>
  710. </div>
  711. <div class="versionchanged">
  712. <p><span class="versionmodified changed">Changed in version 3.10: </span>Added the <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">warn_default_encoding</span></code> option.
  713. Removed the <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">oldparser</span></code> option.</p>
  714. </div>
  715. <div class="versionchanged">
  716. <p><span class="versionmodified changed">Changed in version 3.11: </span>Added the <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">no_debug_ranges</span></code>, <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">frozen_modules</span></code> and
  717. <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">int_max_str_digits</span></code> options.</p>
  718. </div>
  719. <div class="versionchanged">
  720. <p><span class="versionmodified changed">Changed in version 3.12: </span>Added the <code class="docutils literal notranslate"><span class="pre">-X</span> <span class="pre">perf</span></code> option.</p>
  721. </div>
  722. </dd></dl>
  723. </section>
  724. <section id="options-you-shouldn-t-use">
  725. <h3><span class="section-number">1.1.4. </span>Options you shouldn’t use<a class="headerlink" href="#options-you-shouldn-t-use" title="Link to this heading">¶</a></h3>
  726. <dl class="std option">
  727. <dt class="sig sig-object std" id="cmdoption-J">
  728. <span class="sig-name descname"><span class="pre">-J</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-J" title="Link to this definition">¶</a></dt>
  729. <dd><p>Reserved for use by <a class="reference external" href="https://www.jython.org/">Jython</a>.</p>
  730. </dd></dl>
  731. </section>
  732. </section>
  733. <section id="environment-variables">
  734. <span id="using-on-envvars"></span><h2><span class="section-number">1.2. </span>Environment variables<a class="headerlink" href="#environment-variables" title="Link to this heading">¶</a></h2>
  735. <p>These environment variables influence Python’s behavior, they are processed
  736. before the command-line switches other than -E or -I. It is customary that
  737. command-line switches override environmental variables where there is a
  738. conflict.</p>
  739. <dl class="std envvar">
  740. <dt class="sig sig-object std" id="envvar-PYTHONHOME">
  741. <span class="sig-name descname"><span class="pre">PYTHONHOME</span></span><a class="headerlink" href="#envvar-PYTHONHOME" title="Link to this definition">¶</a></dt>
  742. <dd><p>Change the location of the standard Python libraries. By default, the
  743. libraries are searched in <code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">version</span></em></code> and
  744. <code class="file docutils literal notranslate"><em><span class="pre">exec_prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">version</span></em></code>, where <code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em></code> and
  745. <code class="file docutils literal notranslate"><em><span class="pre">exec_prefix</span></em></code> are installation-dependent directories, both defaulting
  746. to <code class="file docutils literal notranslate"><span class="pre">/usr/local</span></code>.</p>
  747. <p>When <span class="target" id="index-30"></span><a class="reference internal" href="#envvar-PYTHONHOME"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHOME</span></code></a> is set to a single directory, its value replaces
  748. both <code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em></code> and <code class="file docutils literal notranslate"><em><span class="pre">exec_prefix</span></em></code>. To specify different values
  749. for these, set <span class="target" id="index-31"></span><a class="reference internal" href="#envvar-PYTHONHOME"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHOME</span></code></a> to <code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em><span class="pre">:</span><em><span class="pre">exec_prefix</span></em></code>.</p>
  750. </dd></dl>
  751. <dl class="std envvar">
  752. <dt class="sig sig-object std" id="envvar-PYTHONPATH">
  753. <span class="sig-name descname"><span class="pre">PYTHONPATH</span></span><a class="headerlink" href="#envvar-PYTHONPATH" title="Link to this definition">¶</a></dt>
  754. <dd><p>Augment the default search path for module files. The format is the same as
  755. the shell’s <span class="target" id="index-32"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code>: one or more directory pathnames separated by
  756. <a class="reference internal" href="../library/os.html#os.pathsep" title="os.pathsep"><code class="xref py py-data docutils literal notranslate"><span class="pre">os.pathsep</span></code></a> (e.g. colons on Unix or semicolons on Windows).
  757. Non-existent directories are silently ignored.</p>
  758. <p>In addition to normal directories, individual <span class="target" id="index-33"></span><a class="reference internal" href="#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPATH</span></code></a> entries
  759. may refer to zipfiles containing pure Python modules (in either source or
  760. compiled form). Extension modules cannot be imported from zipfiles.</p>
  761. <p>The default search path is installation dependent, but generally begins with
  762. <code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">version</span></em></code> (see <span class="target" id="index-34"></span><a class="reference internal" href="#envvar-PYTHONHOME"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHOME</span></code></a> above). It
  763. is <em>always</em> appended to <span class="target" id="index-35"></span><a class="reference internal" href="#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPATH</span></code></a>.</p>
  764. <p>An additional directory will be inserted in the search path in front of
  765. <span class="target" id="index-36"></span><a class="reference internal" href="#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPATH</span></code></a> as described above under
  766. <a class="reference internal" href="#using-on-interface-options"><span class="std std-ref">Interface options</span></a>. The search path can be manipulated from
  767. within a Python program as the variable <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>.</p>
  768. </dd></dl>
  769. <dl class="std envvar">
  770. <dt class="sig sig-object std" id="envvar-PYTHONSAFEPATH">
  771. <span class="sig-name descname"><span class="pre">PYTHONSAFEPATH</span></span><a class="headerlink" href="#envvar-PYTHONSAFEPATH" title="Link to this definition">¶</a></dt>
  772. <dd><p>If this is set to a non-empty string, don’t prepend a potentially unsafe
  773. path to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>: see the <a class="reference internal" href="#cmdoption-P"><code class="xref std std-option docutils literal notranslate"><span class="pre">-P</span></code></a> option for details.</p>
  774. <div class="versionadded">
  775. <p><span class="versionmodified added">New in version 3.11.</span></p>
  776. </div>
  777. </dd></dl>
  778. <dl class="std envvar">
  779. <dt class="sig sig-object std" id="envvar-PYTHONPLATLIBDIR">
  780. <span class="sig-name descname"><span class="pre">PYTHONPLATLIBDIR</span></span><a class="headerlink" href="#envvar-PYTHONPLATLIBDIR" title="Link to this definition">¶</a></dt>
  781. <dd><p>If this is set to a non-empty string, it overrides the <a class="reference internal" href="../library/sys.html#sys.platlibdir" title="sys.platlibdir"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.platlibdir</span></code></a>
  782. value.</p>
  783. <div class="versionadded">
  784. <p><span class="versionmodified added">New in version 3.9.</span></p>
  785. </div>
  786. </dd></dl>
  787. <dl class="std envvar">
  788. <dt class="sig sig-object std" id="envvar-PYTHONSTARTUP">
  789. <span class="sig-name descname"><span class="pre">PYTHONSTARTUP</span></span><a class="headerlink" href="#envvar-PYTHONSTARTUP" title="Link to this definition">¶</a></dt>
  790. <dd><p>If this is the name of a readable file, the Python commands in that file are
  791. executed before the first prompt is displayed in interactive mode. The file
  792. is executed in the same namespace where interactive commands are executed so
  793. that objects defined or imported in it can be used without qualification in
  794. the interactive session. You can also change the prompts <a class="reference internal" href="../library/sys.html#sys.ps1" title="sys.ps1"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.ps1</span></code></a> and
  795. <a class="reference internal" href="../library/sys.html#sys.ps2" title="sys.ps2"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.ps2</span></code></a> and the hook <a class="reference internal" href="../library/sys.html#sys.__interactivehook__" title="sys.__interactivehook__"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.__interactivehook__</span></code></a> in this file.</p>
  796. <p class="audit-hook"><p>Raises an <a class="reference internal" href="../library/sys.html#auditing"><span class="std std-ref">auditing event</span></a> <code class="docutils literal notranslate"><span class="pre">cpython.run_startup</span></code> with
  797. the filename as the argument when called on startup.</p>
  798. </p>
  799. </dd></dl>
  800. <dl class="std envvar">
  801. <dt class="sig sig-object std" id="envvar-PYTHONOPTIMIZE">
  802. <span class="sig-name descname"><span class="pre">PYTHONOPTIMIZE</span></span><a class="headerlink" href="#envvar-PYTHONOPTIMIZE" title="Link to this definition">¶</a></dt>
  803. <dd><p>If this is set to a non-empty string it is equivalent to specifying the
  804. <a class="reference internal" href="#cmdoption-O"><code class="xref std std-option docutils literal notranslate"><span class="pre">-O</span></code></a> option. If set to an integer, it is equivalent to specifying
  805. <a class="reference internal" href="#cmdoption-O"><code class="xref std std-option docutils literal notranslate"><span class="pre">-O</span></code></a> multiple times.</p>
  806. </dd></dl>
  807. <dl class="std envvar">
  808. <dt class="sig sig-object std" id="envvar-PYTHONBREAKPOINT">
  809. <span class="sig-name descname"><span class="pre">PYTHONBREAKPOINT</span></span><a class="headerlink" href="#envvar-PYTHONBREAKPOINT" title="Link to this definition">¶</a></dt>
  810. <dd><p>If this is set, it names a callable using dotted-path notation. The module
  811. containing the callable will be imported and then the callable will be run
  812. by the default implementation of <a class="reference internal" href="../library/sys.html#sys.breakpointhook" title="sys.breakpointhook"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.breakpointhook()</span></code></a> which itself is
  813. called by built-in <a class="reference internal" href="../library/functions.html#breakpoint" title="breakpoint"><code class="xref py py-func docutils literal notranslate"><span class="pre">breakpoint()</span></code></a>. If not set, or set to the empty
  814. string, it is equivalent to the value “pdb.set_trace”. Setting this to the
  815. string “0” causes the default implementation of <a class="reference internal" href="../library/sys.html#sys.breakpointhook" title="sys.breakpointhook"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.breakpointhook()</span></code></a>
  816. to do nothing but return immediately.</p>
  817. <div class="versionadded">
  818. <p><span class="versionmodified added">New in version 3.7.</span></p>
  819. </div>
  820. </dd></dl>
  821. <dl class="std envvar">
  822. <dt class="sig sig-object std" id="envvar-PYTHONDEBUG">
  823. <span class="sig-name descname"><span class="pre">PYTHONDEBUG</span></span><a class="headerlink" href="#envvar-PYTHONDEBUG" title="Link to this definition">¶</a></dt>
  824. <dd><p>If this is set to a non-empty string it is equivalent to specifying the
  825. <a class="reference internal" href="#cmdoption-d"><code class="xref std std-option docutils literal notranslate"><span class="pre">-d</span></code></a> option. If set to an integer, it is equivalent to specifying
  826. <a class="reference internal" href="#cmdoption-d"><code class="xref std std-option docutils literal notranslate"><span class="pre">-d</span></code></a> multiple times.</p>
  827. <p>This environment variable requires a <a class="reference internal" href="configure.html#debug-build"><span class="std std-ref">debug build of Python</span></a>, otherwise it’s ignored.</p>
  828. </dd></dl>
  829. <dl class="std envvar">
  830. <dt class="sig sig-object std" id="envvar-PYTHONINSPECT">
  831. <span class="sig-name descname"><span class="pre">PYTHONINSPECT</span></span><a class="headerlink" href="#envvar-PYTHONINSPECT" title="Link to this definition">¶</a></dt>
  832. <dd><p>If this is set to a non-empty string it is equivalent to specifying the
  833. <a class="reference internal" href="#cmdoption-i"><code class="xref std std-option docutils literal notranslate"><span class="pre">-i</span></code></a> option.</p>
  834. <p>This variable can also be modified by Python code using <a class="reference internal" href="../library/os.html#os.environ" title="os.environ"><code class="xref py py-data docutils literal notranslate"><span class="pre">os.environ</span></code></a>
  835. to force inspect mode on program termination.</p>
  836. </dd></dl>
  837. <dl class="std envvar">
  838. <dt class="sig sig-object std" id="envvar-PYTHONUNBUFFERED">
  839. <span class="sig-name descname"><span class="pre">PYTHONUNBUFFERED</span></span><a class="headerlink" href="#envvar-PYTHONUNBUFFERED" title="Link to this definition">¶</a></dt>
  840. <dd><p>If this is set to a non-empty string it is equivalent to specifying the
  841. <a class="reference internal" href="#cmdoption-u"><code class="xref std std-option docutils literal notranslate"><span class="pre">-u</span></code></a> option.</p>
  842. </dd></dl>
  843. <dl class="std envvar">
  844. <dt class="sig sig-object std" id="envvar-PYTHONVERBOSE">
  845. <span class="sig-name descname"><span class="pre">PYTHONVERBOSE</span></span><a class="headerlink" href="#envvar-PYTHONVERBOSE" title="Link to this definition">¶</a></dt>
  846. <dd><p>If this is set to a non-empty string it is equivalent to specifying the
  847. <a class="reference internal" href="#cmdoption-v"><code class="xref std std-option docutils literal notranslate"><span class="pre">-v</span></code></a> option. If set to an integer, it is equivalent to specifying
  848. <a class="reference internal" href="#cmdoption-v"><code class="xref std std-option docutils literal notranslate"><span class="pre">-v</span></code></a> multiple times.</p>
  849. </dd></dl>
  850. <dl class="std envvar">
  851. <dt class="sig sig-object std" id="envvar-PYTHONCASEOK">
  852. <span class="sig-name descname"><span class="pre">PYTHONCASEOK</span></span><a class="headerlink" href="#envvar-PYTHONCASEOK" title="Link to this definition">¶</a></dt>
  853. <dd><p>If this is set, Python ignores case in <a class="reference internal" href="../reference/simple_stmts.html#import"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">import</span></code></a> statements. This
  854. only works on Windows and macOS.</p>
  855. </dd></dl>
  856. <dl class="std envvar">
  857. <dt class="sig sig-object std" id="envvar-PYTHONDONTWRITEBYTECODE">
  858. <span class="sig-name descname"><span class="pre">PYTHONDONTWRITEBYTECODE</span></span><a class="headerlink" href="#envvar-PYTHONDONTWRITEBYTECODE" title="Link to this definition">¶</a></dt>
  859. <dd><p>If this is set to a non-empty string, Python won’t try to write <code class="docutils literal notranslate"><span class="pre">.pyc</span></code>
  860. files on the import of source modules. This is equivalent to
  861. specifying the <a class="reference internal" href="#cmdoption-B"><code class="xref std std-option docutils literal notranslate"><span class="pre">-B</span></code></a> option.</p>
  862. </dd></dl>
  863. <dl class="std envvar">
  864. <dt class="sig sig-object std" id="envvar-PYTHONPYCACHEPREFIX">
  865. <span class="sig-name descname"><span class="pre">PYTHONPYCACHEPREFIX</span></span><a class="headerlink" href="#envvar-PYTHONPYCACHEPREFIX" title="Link to this definition">¶</a></dt>
  866. <dd><p>If this is set, Python will write <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files in a mirror directory tree
  867. at this path, instead of in <code class="docutils literal notranslate"><span class="pre">__pycache__</span></code> directories within the source
  868. tree. This is equivalent to specifying the <a class="reference internal" href="#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a>
  869. <code class="docutils literal notranslate"><span class="pre">pycache_prefix=PATH</span></code> option.</p>
  870. <div class="versionadded">
  871. <p><span class="versionmodified added">New in version 3.8.</span></p>
  872. </div>
  873. </dd></dl>
  874. <dl class="std envvar">
  875. <dt class="sig sig-object std" id="envvar-PYTHONHASHSEED">
  876. <span class="sig-name descname"><span class="pre">PYTHONHASHSEED</span></span><a class="headerlink" href="#envvar-PYTHONHASHSEED" title="Link to this definition">¶</a></dt>
  877. <dd><p>If this variable is not set or set to <code class="docutils literal notranslate"><span class="pre">random</span></code>, a random value is used
  878. to seed the hashes of str and bytes objects.</p>
  879. <p>If <span class="target" id="index-37"></span><a class="reference internal" href="#envvar-PYTHONHASHSEED"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHASHSEED</span></code></a> is set to an integer value, it is used as a fixed
  880. seed for generating the hash() of the types covered by the hash
  881. randomization.</p>
  882. <p>Its purpose is to allow repeatable hashing, such as for selftests for the
  883. interpreter itself, or to allow a cluster of python processes to share hash
  884. values.</p>
  885. <p>The integer must be a decimal number in the range [0,4294967295]. Specifying
  886. the value 0 will disable hash randomization.</p>
  887. <div class="versionadded">
  888. <p><span class="versionmodified added">New in version 3.2.3.</span></p>
  889. </div>
  890. </dd></dl>
  891. <dl class="std envvar">
  892. <dt class="sig sig-object std" id="envvar-PYTHONINTMAXSTRDIGITS">
  893. <span class="sig-name descname"><span class="pre">PYTHONINTMAXSTRDIGITS</span></span><a class="headerlink" href="#envvar-PYTHONINTMAXSTRDIGITS" title="Link to this definition">¶</a></dt>
  894. <dd><p>If this variable is set to an integer, it is used to configure the
  895. interpreter’s global <a class="reference internal" href="../library/stdtypes.html#int-max-str-digits"><span class="std std-ref">integer string conversion length limitation</span></a>.</p>
  896. <div class="versionadded">
  897. <p><span class="versionmodified added">New in version 3.11.</span></p>
  898. </div>
  899. </dd></dl>
  900. <dl class="std envvar">
  901. <dt class="sig sig-object std" id="envvar-PYTHONIOENCODING">
  902. <span class="sig-name descname"><span class="pre">PYTHONIOENCODING</span></span><a class="headerlink" href="#envvar-PYTHONIOENCODING" title="Link to this definition">¶</a></dt>
  903. <dd><p>If this is set before running the interpreter, it overrides the encoding used
  904. for stdin/stdout/stderr, in the syntax <code class="docutils literal notranslate"><span class="pre">encodingname:errorhandler</span></code>. Both
  905. the <code class="docutils literal notranslate"><span class="pre">encodingname</span></code> and the <code class="docutils literal notranslate"><span class="pre">:errorhandler</span></code> parts are optional and have
  906. the same meaning as in <a class="reference internal" href="../library/stdtypes.html#str.encode" title="str.encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">str.encode()</span></code></a>.</p>
  907. <p>For stderr, the <code class="docutils literal notranslate"><span class="pre">:errorhandler</span></code> part is ignored; the handler will always be
  908. <code class="docutils literal notranslate"><span class="pre">'backslashreplace'</span></code>.</p>
  909. <div class="versionchanged">
  910. <p><span class="versionmodified changed">Changed in version 3.4: </span>The <code class="docutils literal notranslate"><span class="pre">encodingname</span></code> part is now optional.</p>
  911. </div>
  912. <div class="versionchanged">
  913. <p><span class="versionmodified changed">Changed in version 3.6: </span>On Windows, the encoding specified by this variable is ignored for interactive
  914. console buffers unless <span class="target" id="index-38"></span><a class="reference internal" href="#envvar-PYTHONLEGACYWINDOWSSTDIO"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONLEGACYWINDOWSSTDIO</span></code></a> is also specified.
  915. Files and pipes redirected through the standard streams are not affected.</p>
  916. </div>
  917. </dd></dl>
  918. <dl class="std envvar">
  919. <dt class="sig sig-object std" id="envvar-PYTHONNOUSERSITE">
  920. <span class="sig-name descname"><span class="pre">PYTHONNOUSERSITE</span></span><a class="headerlink" href="#envvar-PYTHONNOUSERSITE" title="Link to this definition">¶</a></dt>
  921. <dd><p>If this is set, Python won’t add the <a class="reference internal" href="../library/site.html#site.USER_SITE" title="site.USER_SITE"><code class="xref py py-data docutils literal notranslate"><span class="pre">user</span> <span class="pre">site-packages</span> <span class="pre">directory</span></code></a> to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>.</p>
  922. <div class="admonition seealso">
  923. <p class="admonition-title">See also</p>
  924. <p><span class="target" id="index-39"></span><a class="pep reference external" href="https://peps.python.org/pep-0370/"><strong>PEP 370</strong></a> – Per user site-packages directory</p>
  925. </div>
  926. </dd></dl>
  927. <dl class="std envvar">
  928. <dt class="sig sig-object std" id="envvar-PYTHONUSERBASE">
  929. <span class="sig-name descname"><span class="pre">PYTHONUSERBASE</span></span><a class="headerlink" href="#envvar-PYTHONUSERBASE" title="Link to this definition">¶</a></dt>
  930. <dd><p>Defines the <a class="reference internal" href="../library/site.html#site.USER_BASE" title="site.USER_BASE"><code class="xref py py-data docutils literal notranslate"><span class="pre">user</span> <span class="pre">base</span> <span class="pre">directory</span></code></a>, which is used to
  931. compute the path of the <a class="reference internal" href="../library/site.html#site.USER_SITE" title="site.USER_SITE"><code class="xref py py-data docutils literal notranslate"><span class="pre">user</span> <span class="pre">site-packages</span> <span class="pre">directory</span></code></a>
  932. and <a class="reference internal" href="../library/sysconfig.html#sysconfig-user-scheme"><span class="std std-ref">installation paths</span></a> for
  933. <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">pip</span> <span class="pre">install</span> <span class="pre">--user</span></code>.</p>
  934. <div class="admonition seealso">
  935. <p class="admonition-title">See also</p>
  936. <p><span class="target" id="index-40"></span><a class="pep reference external" href="https://peps.python.org/pep-0370/"><strong>PEP 370</strong></a> – Per user site-packages directory</p>
  937. </div>
  938. </dd></dl>
  939. <dl class="std envvar">
  940. <dt class="sig sig-object std" id="envvar-PYTHONEXECUTABLE">
  941. <span class="sig-name descname"><span class="pre">PYTHONEXECUTABLE</span></span><a class="headerlink" href="#envvar-PYTHONEXECUTABLE" title="Link to this definition">¶</a></dt>
  942. <dd><p>If this environment variable is set, <code class="docutils literal notranslate"><span class="pre">sys.argv[0]</span></code> will be set to its
  943. value instead of the value got through the C runtime. Only works on
  944. macOS.</p>
  945. </dd></dl>
  946. <dl class="std envvar">
  947. <dt class="sig sig-object std" id="envvar-PYTHONWARNINGS">
  948. <span class="sig-name descname"><span class="pre">PYTHONWARNINGS</span></span><a class="headerlink" href="#envvar-PYTHONWARNINGS" title="Link to this definition">¶</a></dt>
  949. <dd><p>This is equivalent to the <a class="reference internal" href="#cmdoption-W"><code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code></a> option. If set to a comma
  950. separated string, it is equivalent to specifying <a class="reference internal" href="#cmdoption-W"><code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code></a> multiple
  951. times, with filters later in the list taking precedence over those earlier
  952. in the list.</p>
  953. <p>The simplest settings apply a particular action unconditionally to all
  954. warnings emitted by a process (even those that are otherwise ignored by
  955. default):</p>
  956. <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="nv">PYTHONWARNINGS</span><span class="o">=</span>default<span class="w"> </span><span class="c1"># Warn once per call location</span>
  957. <span class="nv">PYTHONWARNINGS</span><span class="o">=</span>error<span class="w"> </span><span class="c1"># Convert to exceptions</span>
  958. <span class="nv">PYTHONWARNINGS</span><span class="o">=</span>always<span class="w"> </span><span class="c1"># Warn every time</span>
  959. <span class="nv">PYTHONWARNINGS</span><span class="o">=</span>module<span class="w"> </span><span class="c1"># Warn once per calling module</span>
  960. <span class="nv">PYTHONWARNINGS</span><span class="o">=</span>once<span class="w"> </span><span class="c1"># Warn once per Python process</span>
  961. <span class="nv">PYTHONWARNINGS</span><span class="o">=</span>ignore<span class="w"> </span><span class="c1"># Never warn</span>
  962. </pre></div>
  963. </div>
  964. <p>See <a class="reference internal" href="../library/warnings.html#warning-filter"><span class="std std-ref">The Warnings Filter</span></a> and <a class="reference internal" href="../library/warnings.html#describing-warning-filters"><span class="std std-ref">Describing Warning Filters</span></a> for more
  965. details.</p>
  966. </dd></dl>
  967. <dl class="std envvar">
  968. <dt class="sig sig-object std" id="envvar-PYTHONFAULTHANDLER">
  969. <span class="sig-name descname"><span class="pre">PYTHONFAULTHANDLER</span></span><a class="headerlink" href="#envvar-PYTHONFAULTHANDLER" title="Link to this definition">¶</a></dt>
  970. <dd><p>If this environment variable is set to a non-empty string,
  971. <a class="reference internal" href="../library/faulthandler.html#faulthandler.enable" title="faulthandler.enable"><code class="xref py py-func docutils literal notranslate"><span class="pre">faulthandler.enable()</span></code></a> is called at startup: install a handler for
  972. <a class="reference internal" href="../library/signal.html#signal.SIGSEGV" title="signal.SIGSEGV"><code class="xref py py-const docutils literal notranslate"><span class="pre">SIGSEGV</span></code></a>, <a class="reference internal" href="../library/signal.html#signal.SIGFPE" title="signal.SIGFPE"><code class="xref py py-const docutils literal notranslate"><span class="pre">SIGFPE</span></code></a>,
  973. <a class="reference internal" href="../library/signal.html#signal.SIGABRT" title="signal.SIGABRT"><code class="xref py py-const docutils literal notranslate"><span class="pre">SIGABRT</span></code></a>, <a class="reference internal" href="../library/signal.html#signal.SIGBUS" title="signal.SIGBUS"><code class="xref py py-const docutils literal notranslate"><span class="pre">SIGBUS</span></code></a> and
  974. <a class="reference internal" href="../library/signal.html#signal.SIGILL" title="signal.SIGILL"><code class="xref py py-const docutils literal notranslate"><span class="pre">SIGILL</span></code></a> signals to dump the Python traceback.
  975. This is equivalent to <a class="reference internal" href="#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">faulthandler</span></code> option.</p>
  976. <div class="versionadded">
  977. <p><span class="versionmodified added">New in version 3.3.</span></p>
  978. </div>
  979. </dd></dl>
  980. <dl class="std envvar">
  981. <dt class="sig sig-object std" id="envvar-PYTHONTRACEMALLOC">
  982. <span class="sig-name descname"><span class="pre">PYTHONTRACEMALLOC</span></span><a class="headerlink" href="#envvar-PYTHONTRACEMALLOC" title="Link to this definition">¶</a></dt>
  983. <dd><p>If this environment variable is set to a non-empty string, start tracing
  984. Python memory allocations using the <a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tracemalloc</span></code></a> module. The value of
  985. the variable is the maximum number of frames stored in a traceback of a
  986. trace. For example, <code class="docutils literal notranslate"><span class="pre">PYTHONTRACEMALLOC=1</span></code> stores only the most recent
  987. frame.
  988. See the <a class="reference internal" href="../library/tracemalloc.html#tracemalloc.start" title="tracemalloc.start"><code class="xref py py-func docutils literal notranslate"><span class="pre">tracemalloc.start()</span></code></a> function for more information.
  989. This is equivalent to setting the <a class="reference internal" href="#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">tracemalloc</span></code> option.</p>
  990. <div class="versionadded">
  991. <p><span class="versionmodified added">New in version 3.4.</span></p>
  992. </div>
  993. </dd></dl>
  994. <dl class="std envvar">
  995. <dt class="sig sig-object std" id="envvar-PYTHONPROFILEIMPORTTIME">
  996. <span class="sig-name descname"><span class="pre">PYTHONPROFILEIMPORTTIME</span></span><a class="headerlink" href="#envvar-PYTHONPROFILEIMPORTTIME" title="Link to this definition">¶</a></dt>
  997. <dd><p>If this environment variable is set to a non-empty string, Python will
  998. show how long each import takes.
  999. This is equivalent to setting the <a class="reference internal" href="#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">importtime</span></code> option.</p>
  1000. <div class="versionadded">
  1001. <p><span class="versionmodified added">New in version 3.7.</span></p>
  1002. </div>
  1003. </dd></dl>
  1004. <dl class="std envvar">
  1005. <dt class="sig sig-object std" id="envvar-PYTHONASYNCIODEBUG">
  1006. <span class="sig-name descname"><span class="pre">PYTHONASYNCIODEBUG</span></span><a class="headerlink" href="#envvar-PYTHONASYNCIODEBUG" title="Link to this definition">¶</a></dt>
  1007. <dd><p>If this environment variable is set to a non-empty string, enable the
  1008. <a class="reference internal" href="../library/asyncio-dev.html#asyncio-debug-mode"><span class="std std-ref">debug mode</span></a> of the <a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a> module.</p>
  1009. <div class="versionadded">
  1010. <p><span class="versionmodified added">New in version 3.4.</span></p>
  1011. </div>
  1012. </dd></dl>
  1013. <dl class="std envvar">
  1014. <dt class="sig sig-object std" id="envvar-PYTHONMALLOC">
  1015. <span class="sig-name descname"><span class="pre">PYTHONMALLOC</span></span><a class="headerlink" href="#envvar-PYTHONMALLOC" title="Link to this definition">¶</a></dt>
  1016. <dd><p>Set the Python memory allocators and/or install debug hooks.</p>
  1017. <p>Set the family of memory allocators used by Python:</p>
  1018. <ul class="simple">
  1019. <li><p><code class="docutils literal notranslate"><span class="pre">default</span></code>: use the <a class="reference internal" href="../c-api/memory.html#default-memory-allocators"><span class="std std-ref">default memory allocators</span></a>.</p></li>
  1020. <li><p><code class="docutils literal notranslate"><span class="pre">malloc</span></code>: use the <code class="xref c c-func docutils literal notranslate"><span class="pre">malloc()</span></code> function of the C library
  1021. for all domains (<a class="reference internal" href="../c-api/memory.html#c.PYMEM_DOMAIN_RAW" title="PYMEM_DOMAIN_RAW"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PYMEM_DOMAIN_RAW</span></code></a>, <a class="reference internal" href="../c-api/memory.html#c.PYMEM_DOMAIN_MEM" title="PYMEM_DOMAIN_MEM"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PYMEM_DOMAIN_MEM</span></code></a>,
  1022. <a class="reference internal" href="../c-api/memory.html#c.PYMEM_DOMAIN_OBJ" title="PYMEM_DOMAIN_OBJ"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PYMEM_DOMAIN_OBJ</span></code></a>).</p></li>
  1023. <li><p><code class="docutils literal notranslate"><span class="pre">pymalloc</span></code>: use the <a class="reference internal" href="../c-api/memory.html#pymalloc"><span class="std std-ref">pymalloc allocator</span></a> for
  1024. <a class="reference internal" href="../c-api/memory.html#c.PYMEM_DOMAIN_MEM" title="PYMEM_DOMAIN_MEM"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PYMEM_DOMAIN_MEM</span></code></a> and <a class="reference internal" href="../c-api/memory.html#c.PYMEM_DOMAIN_OBJ" title="PYMEM_DOMAIN_OBJ"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PYMEM_DOMAIN_OBJ</span></code></a> domains and use
  1025. the <code class="xref c c-func docutils literal notranslate"><span class="pre">malloc()</span></code> function for the <a class="reference internal" href="../c-api/memory.html#c.PYMEM_DOMAIN_RAW" title="PYMEM_DOMAIN_RAW"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PYMEM_DOMAIN_RAW</span></code></a> domain.</p></li>
  1026. </ul>
  1027. <p>Install <a class="reference internal" href="../c-api/memory.html#pymem-debug-hooks"><span class="std std-ref">debug hooks</span></a>:</p>
  1028. <ul class="simple">
  1029. <li><p><code class="docutils literal notranslate"><span class="pre">debug</span></code>: install debug hooks on top of the <a class="reference internal" href="../c-api/memory.html#default-memory-allocators"><span class="std std-ref">default memory
  1030. allocators</span></a>.</p></li>
  1031. <li><p><code class="docutils literal notranslate"><span class="pre">malloc_debug</span></code>: same as <code class="docutils literal notranslate"><span class="pre">malloc</span></code> but also install debug hooks.</p></li>
  1032. <li><p><code class="docutils literal notranslate"><span class="pre">pymalloc_debug</span></code>: same as <code class="docutils literal notranslate"><span class="pre">pymalloc</span></code> but also install debug hooks.</p></li>
  1033. </ul>
  1034. <div class="versionadded">
  1035. <p><span class="versionmodified added">New in version 3.6.</span></p>
  1036. </div>
  1037. <div class="versionchanged">
  1038. <p><span class="versionmodified changed">Changed in version 3.7: </span>Added the <code class="docutils literal notranslate"><span class="pre">&quot;default&quot;</span></code> allocator.</p>
  1039. </div>
  1040. </dd></dl>
  1041. <dl class="std envvar">
  1042. <dt class="sig sig-object std" id="envvar-PYTHONMALLOCSTATS">
  1043. <span class="sig-name descname"><span class="pre">PYTHONMALLOCSTATS</span></span><a class="headerlink" href="#envvar-PYTHONMALLOCSTATS" title="Link to this definition">¶</a></dt>
  1044. <dd><p>If set to a non-empty string, Python will print statistics of the
  1045. <a class="reference internal" href="../c-api/memory.html#pymalloc"><span class="std std-ref">pymalloc memory allocator</span></a> every time a new pymalloc object
  1046. arena is created, and on shutdown.</p>
  1047. <p>This variable is ignored if the <span class="target" id="index-41"></span><a class="reference internal" href="#envvar-PYTHONMALLOC"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONMALLOC</span></code></a> environment variable
  1048. is used to force the <code class="xref c c-func docutils literal notranslate"><span class="pre">malloc()</span></code> allocator of the C library, or if
  1049. Python is configured without <code class="docutils literal notranslate"><span class="pre">pymalloc</span></code> support.</p>
  1050. <div class="versionchanged">
  1051. <p><span class="versionmodified changed">Changed in version 3.6: </span>This variable can now also be used on Python compiled in release mode.
  1052. It now has no effect if set to an empty string.</p>
  1053. </div>
  1054. </dd></dl>
  1055. <dl class="std envvar">
  1056. <dt class="sig sig-object std" id="envvar-PYTHONLEGACYWINDOWSFSENCODING">
  1057. <span class="sig-name descname"><span class="pre">PYTHONLEGACYWINDOWSFSENCODING</span></span><a class="headerlink" href="#envvar-PYTHONLEGACYWINDOWSFSENCODING" title="Link to this definition">¶</a></dt>
  1058. <dd><p>If set to a non-empty string, the default <a class="reference internal" href="../glossary.html#term-filesystem-encoding-and-error-handler"><span class="xref std std-term">filesystem encoding and
  1059. error handler</span></a> mode will revert to their pre-3.6 values of ‘mbcs’ and
  1060. ‘replace’, respectively. Otherwise, the new defaults ‘utf-8’ and
  1061. ‘surrogatepass’ are used.</p>
  1062. <p>This may also be enabled at runtime with
  1063. <a class="reference internal" href="../library/sys.html#sys._enablelegacywindowsfsencoding" title="sys._enablelegacywindowsfsencoding"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys._enablelegacywindowsfsencoding()</span></code></a>.</p>
  1064. <div class="availability docutils container">
  1065. <p><a class="reference internal" href="../library/intro.html#availability"><span class="std std-ref">Availability</span></a>: Windows.</p>
  1066. </div>
  1067. <div class="versionadded">
  1068. <p><span class="versionmodified added">New in version 3.6: </span>See <span class="target" id="index-42"></span><a class="pep reference external" href="https://peps.python.org/pep-0529/"><strong>PEP 529</strong></a> for more details.</p>
  1069. </div>
  1070. </dd></dl>
  1071. <dl class="std envvar">
  1072. <dt class="sig sig-object std" id="envvar-PYTHONLEGACYWINDOWSSTDIO">
  1073. <span class="sig-name descname"><span class="pre">PYTHONLEGACYWINDOWSSTDIO</span></span><a class="headerlink" href="#envvar-PYTHONLEGACYWINDOWSSTDIO" title="Link to this definition">¶</a></dt>
  1074. <dd><p>If set to a non-empty string, does not use the new console reader and
  1075. writer. This means that Unicode characters will be encoded according to
  1076. the active console code page, rather than using utf-8.</p>
  1077. <p>This variable is ignored if the standard streams are redirected (to files
  1078. or pipes) rather than referring to console buffers.</p>
  1079. <div class="availability docutils container">
  1080. <p><a class="reference internal" href="../library/intro.html#availability"><span class="std std-ref">Availability</span></a>: Windows.</p>
  1081. </div>
  1082. <div class="versionadded">
  1083. <p><span class="versionmodified added">New in version 3.6.</span></p>
  1084. </div>
  1085. </dd></dl>
  1086. <dl class="std envvar">
  1087. <dt class="sig sig-object std" id="envvar-PYTHONCOERCECLOCALE">
  1088. <span class="sig-name descname"><span class="pre">PYTHONCOERCECLOCALE</span></span><a class="headerlink" href="#envvar-PYTHONCOERCECLOCALE" title="Link to this definition">¶</a></dt>
  1089. <dd><p>If set to the value <code class="docutils literal notranslate"><span class="pre">0</span></code>, causes the main Python command line application
  1090. to skip coercing the legacy ASCII-based C and POSIX locales to a more
  1091. capable UTF-8 based alternative.</p>
  1092. <p>If this variable is <em>not</em> set (or is set to a value other than <code class="docutils literal notranslate"><span class="pre">0</span></code>), the
  1093. <code class="docutils literal notranslate"><span class="pre">LC_ALL</span></code> locale override environment variable is also not set, and the
  1094. current locale reported for the <code class="docutils literal notranslate"><span class="pre">LC_CTYPE</span></code> category is either the default
  1095. <code class="docutils literal notranslate"><span class="pre">C</span></code> locale, or else the explicitly ASCII-based <code class="docutils literal notranslate"><span class="pre">POSIX</span></code> locale, then the
  1096. Python CLI will attempt to configure the following locales for the
  1097. <code class="docutils literal notranslate"><span class="pre">LC_CTYPE</span></code> category in the order listed before loading the interpreter
  1098. runtime:</p>
  1099. <ul class="simple">
  1100. <li><p><code class="docutils literal notranslate"><span class="pre">C.UTF-8</span></code></p></li>
  1101. <li><p><code class="docutils literal notranslate"><span class="pre">C.utf8</span></code></p></li>
  1102. <li><p><code class="docutils literal notranslate"><span class="pre">UTF-8</span></code></p></li>
  1103. </ul>
  1104. <p>If setting one of these locale categories succeeds, then the <code class="docutils literal notranslate"><span class="pre">LC_CTYPE</span></code>
  1105. environment variable will also be set accordingly in the current process
  1106. environment before the Python runtime is initialized. This ensures that in
  1107. addition to being seen by both the interpreter itself and other locale-aware
  1108. components running in the same process (such as the GNU <code class="docutils literal notranslate"><span class="pre">readline</span></code>
  1109. library), the updated setting is also seen in subprocesses (regardless of
  1110. whether or not those processes are running a Python interpreter), as well as
  1111. in operations that query the environment rather than the current C locale
  1112. (such as Python’s own <a class="reference internal" href="../library/locale.html#locale.getdefaultlocale" title="locale.getdefaultlocale"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.getdefaultlocale()</span></code></a>).</p>
  1113. <p>Configuring one of these locales (either explicitly or via the above
  1114. implicit locale coercion) automatically enables the <code class="docutils literal notranslate"><span class="pre">surrogateescape</span></code>
  1115. <a class="reference internal" href="../library/codecs.html#error-handlers"><span class="std std-ref">error handler</span></a> for <a class="reference internal" href="../library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdin</span></code></a> and
  1116. <a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout</span></code></a> (<a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stderr</span></code></a> continues to use <code class="docutils literal notranslate"><span class="pre">backslashreplace</span></code>
  1117. as it does in any other locale). This stream handling behavior can be
  1118. overridden using <span class="target" id="index-43"></span><a class="reference internal" href="#envvar-PYTHONIOENCODING"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONIOENCODING</span></code></a> as usual.</p>
  1119. <p>For debugging purposes, setting <code class="docutils literal notranslate"><span class="pre">PYTHONCOERCECLOCALE=warn</span></code> will cause
  1120. Python to emit warning messages on <code class="docutils literal notranslate"><span class="pre">stderr</span></code> if either the locale coercion
  1121. activates, or else if a locale that <em>would</em> have triggered coercion is
  1122. still active when the Python runtime is initialized.</p>
  1123. <p>Also note that even when locale coercion is disabled, or when it fails to
  1124. find a suitable target locale, <span class="target" id="index-44"></span><a class="reference internal" href="#envvar-PYTHONUTF8"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONUTF8</span></code></a> will still activate by
  1125. default in legacy ASCII-based locales. Both features must be disabled in
  1126. order to force the interpreter to use <code class="docutils literal notranslate"><span class="pre">ASCII</span></code> instead of <code class="docutils literal notranslate"><span class="pre">UTF-8</span></code> for
  1127. system interfaces.</p>
  1128. <div class="availability docutils container">
  1129. <p><a class="reference internal" href="../library/intro.html#availability"><span class="std std-ref">Availability</span></a>: Unix.</p>
  1130. </div>
  1131. <div class="versionadded">
  1132. <p><span class="versionmodified added">New in version 3.7: </span>See <span class="target" id="index-45"></span><a class="pep reference external" href="https://peps.python.org/pep-0538/"><strong>PEP 538</strong></a> for more details.</p>
  1133. </div>
  1134. </dd></dl>
  1135. <dl class="std envvar">
  1136. <dt class="sig sig-object std" id="envvar-PYTHONDEVMODE">
  1137. <span class="sig-name descname"><span class="pre">PYTHONDEVMODE</span></span><a class="headerlink" href="#envvar-PYTHONDEVMODE" title="Link to this definition">¶</a></dt>
  1138. <dd><p>If this environment variable is set to a non-empty string, enable
  1139. <a class="reference internal" href="../library/devmode.html#devmode"><span class="std std-ref">Python Development Mode</span></a>, introducing additional runtime
  1140. checks that are too expensive to be enabled by default.
  1141. This is equivalent to setting the <a class="reference internal" href="#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">dev</span></code> option.</p>
  1142. <div class="versionadded">
  1143. <p><span class="versionmodified added">New in version 3.7.</span></p>
  1144. </div>
  1145. </dd></dl>
  1146. <dl class="std envvar">
  1147. <dt class="sig sig-object std" id="envvar-PYTHONUTF8">
  1148. <span class="sig-name descname"><span class="pre">PYTHONUTF8</span></span><a class="headerlink" href="#envvar-PYTHONUTF8" title="Link to this definition">¶</a></dt>
  1149. <dd><p>If set to <code class="docutils literal notranslate"><span class="pre">1</span></code>, enable the <a class="reference internal" href="../library/os.html#utf8-mode"><span class="std std-ref">Python UTF-8 Mode</span></a>.</p>
  1150. <p>If set to <code class="docutils literal notranslate"><span class="pre">0</span></code>, disable the <a class="reference internal" href="../library/os.html#utf8-mode"><span class="std std-ref">Python UTF-8 Mode</span></a>.</p>
  1151. <p>Setting any other non-empty string causes an error during interpreter
  1152. initialisation.</p>
  1153. <div class="versionadded">
  1154. <p><span class="versionmodified added">New in version 3.7.</span></p>
  1155. </div>
  1156. </dd></dl>
  1157. <dl class="std envvar">
  1158. <dt class="sig sig-object std" id="envvar-PYTHONWARNDEFAULTENCODING">
  1159. <span class="sig-name descname"><span class="pre">PYTHONWARNDEFAULTENCODING</span></span><a class="headerlink" href="#envvar-PYTHONWARNDEFAULTENCODING" title="Link to this definition">¶</a></dt>
  1160. <dd><p>If this environment variable is set to a non-empty string, issue a
  1161. <a class="reference internal" href="../library/exceptions.html#EncodingWarning" title="EncodingWarning"><code class="xref py py-class docutils literal notranslate"><span class="pre">EncodingWarning</span></code></a> when the locale-specific default encoding is used.</p>
  1162. <p>See <a class="reference internal" href="../library/io.html#io-encoding-warning"><span class="std std-ref">Opt-in EncodingWarning</span></a> for details.</p>
  1163. <div class="versionadded">
  1164. <p><span class="versionmodified added">New in version 3.10.</span></p>
  1165. </div>
  1166. </dd></dl>
  1167. <dl class="std envvar">
  1168. <dt class="sig sig-object std" id="envvar-PYTHONNODEBUGRANGES">
  1169. <span class="sig-name descname"><span class="pre">PYTHONNODEBUGRANGES</span></span><a class="headerlink" href="#envvar-PYTHONNODEBUGRANGES" title="Link to this definition">¶</a></dt>
  1170. <dd><p>If this variable is set, it disables the inclusion of the tables mapping
  1171. extra location information (end line, start column offset and end column
  1172. offset) to every instruction in code objects. This is useful when smaller
  1173. code objects and pyc files are desired as well as suppressing the extra visual
  1174. location indicators when the interpreter displays tracebacks.</p>
  1175. <div class="versionadded">
  1176. <p><span class="versionmodified added">New in version 3.11.</span></p>
  1177. </div>
  1178. </dd></dl>
  1179. <dl class="std envvar">
  1180. <dt class="sig sig-object std" id="envvar-PYTHONPERFSUPPORT">
  1181. <span class="sig-name descname"><span class="pre">PYTHONPERFSUPPORT</span></span><a class="headerlink" href="#envvar-PYTHONPERFSUPPORT" title="Link to this definition">¶</a></dt>
  1182. <dd><p>If this variable is set to a nonzero value, it enables support for
  1183. the Linux <code class="docutils literal notranslate"><span class="pre">perf</span></code> profiler so Python calls can be detected by it.</p>
  1184. <p>If set to <code class="docutils literal notranslate"><span class="pre">0</span></code>, disable Linux <code class="docutils literal notranslate"><span class="pre">perf</span></code> profiler support.</p>
  1185. <p>See also the <a class="reference internal" href="#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span> <span class="pre">perf</span></code></a> command-line option
  1186. and <a class="reference internal" href="../howto/perf_profiling.html#perf-profiling"><span class="std std-ref">Python support for the Linux perf profiler</span></a>.</p>
  1187. <div class="versionadded">
  1188. <p><span class="versionmodified added">New in version 3.12.</span></p>
  1189. </div>
  1190. </dd></dl>
  1191. <section id="debug-mode-variables">
  1192. <h3><span class="section-number">1.2.1. </span>Debug-mode variables<a class="headerlink" href="#debug-mode-variables" title="Link to this heading">¶</a></h3>
  1193. <dl class="std envvar">
  1194. <dt class="sig sig-object std" id="envvar-PYTHONDUMPREFS">
  1195. <span class="sig-name descname"><span class="pre">PYTHONDUMPREFS</span></span><a class="headerlink" href="#envvar-PYTHONDUMPREFS" title="Link to this definition">¶</a></dt>
  1196. <dd><p>If set, Python will dump objects and reference counts still alive after
  1197. shutting down the interpreter.</p>
  1198. <p>Need Python configured with the <a class="reference internal" href="configure.html#cmdoption-with-trace-refs"><code class="xref std std-option docutils literal notranslate"><span class="pre">--with-trace-refs</span></code></a> build option.</p>
  1199. </dd></dl>
  1200. <dl class="std envvar">
  1201. <dt class="sig sig-object std" id="envvar-PYTHONDUMPREFSFILE-FILENAME">
  1202. <span class="sig-name descname"><span class="pre">PYTHONDUMPREFSFILE=FILENAME</span></span><a class="headerlink" href="#envvar-PYTHONDUMPREFSFILE-FILENAME" title="Link to this definition">¶</a></dt>
  1203. <dd><p>If set, Python will dump objects and reference counts still alive
  1204. after shutting down the interpreter into a file called <em>FILENAME</em>.</p>
  1205. <p>Need Python configured with the <a class="reference internal" href="configure.html#cmdoption-with-trace-refs"><code class="xref std std-option docutils literal notranslate"><span class="pre">--with-trace-refs</span></code></a> build option.</p>
  1206. <div class="versionadded">
  1207. <p><span class="versionmodified added">New in version 3.11.</span></p>
  1208. </div>
  1209. </dd></dl>
  1210. </section>
  1211. </section>
  1212. </section>
  1213. <div class="clearer"></div>
  1214. </div>
  1215. </div>
  1216. </div>
  1217. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  1218. <div class="sphinxsidebarwrapper">
  1219. <div>
  1220. <h3><a href="../contents.html">Table of Contents</a></h3>
  1221. <ul>
  1222. <li><a class="reference internal" href="#">1. Command line and environment</a><ul>
  1223. <li><a class="reference internal" href="#command-line">1.1. Command line</a><ul>
  1224. <li><a class="reference internal" href="#interface-options">1.1.1. Interface options</a></li>
  1225. <li><a class="reference internal" href="#generic-options">1.1.2. Generic options</a></li>
  1226. <li><a class="reference internal" href="#miscellaneous-options">1.1.3. Miscellaneous options</a></li>
  1227. <li><a class="reference internal" href="#options-you-shouldn-t-use">1.1.4. Options you shouldn’t use</a></li>
  1228. </ul>
  1229. </li>
  1230. <li><a class="reference internal" href="#environment-variables">1.2. Environment variables</a><ul>
  1231. <li><a class="reference internal" href="#debug-mode-variables">1.2.1. Debug-mode variables</a></li>
  1232. </ul>
  1233. </li>
  1234. </ul>
  1235. </li>
  1236. </ul>
  1237. </div>
  1238. <div>
  1239. <h4>Previous topic</h4>
  1240. <p class="topless"><a href="index.html"
  1241. title="previous chapter">Python Setup and Usage</a></p>
  1242. </div>
  1243. <div>
  1244. <h4>Next topic</h4>
  1245. <p class="topless"><a href="unix.html"
  1246. title="next chapter"><span class="section-number">2. </span>Using Python on Unix platforms</a></p>
  1247. </div>
  1248. <div role="note" aria-label="source link">
  1249. <h3>This Page</h3>
  1250. <ul class="this-page-menu">
  1251. <li><a href="../bugs.html">Report a Bug</a></li>
  1252. <li>
  1253. <a href="https://github.com/python/cpython/blob/main/Doc/using/cmdline.rst"
  1254. rel="nofollow">Show Source
  1255. </a>
  1256. </li>
  1257. </ul>
  1258. </div>
  1259. </div>
  1260. <div id="sidebarbutton" title="Collapse sidebar">
  1261. <span>«</span>
  1262. </div>
  1263. </div>
  1264. <div class="clearer"></div>
  1265. </div>
  1266. <div class="related" role="navigation" aria-label="related navigation">
  1267. <h3>Navigation</h3>
  1268. <ul>
  1269. <li class="right" style="margin-right: 10px">
  1270. <a href="../genindex.html" title="General Index"
  1271. >index</a></li>
  1272. <li class="right" >
  1273. <a href="../py-modindex.html" title="Python Module Index"
  1274. >modules</a> |</li>
  1275. <li class="right" >
  1276. <a href="unix.html" title="2. Using Python on Unix platforms"
  1277. >next</a> |</li>
  1278. <li class="right" >
  1279. <a href="index.html" title="Python Setup and Usage"
  1280. >previous</a> |</li>
  1281. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  1282. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  1283. <li class="switchers">
  1284. <div class="language_switcher_placeholder"></div>
  1285. <div class="version_switcher_placeholder"></div>
  1286. </li>
  1287. <li>
  1288. </li>
  1289. <li id="cpython-language-and-version">
  1290. <a href="../index.html">3.12.3 Documentation</a> &#187;
  1291. </li>
  1292. <li class="nav-item nav-item-1"><a href="index.html" >Python Setup and Usage</a> &#187;</li>
  1293. <li class="nav-item nav-item-this"><a href=""><span class="section-number">1. </span>Command line and environment</a></li>
  1294. <li class="right">
  1295. <div class="inline-search" role="search">
  1296. <form class="inline-search" action="../search.html" method="get">
  1297. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  1298. <input type="submit" value="Go" />
  1299. </form>
  1300. </div>
  1301. |
  1302. </li>
  1303. <li class="right">
  1304. <label class="theme-selector-label">
  1305. Theme
  1306. <select class="theme-selector" oninput="activateTheme(this.value)">
  1307. <option value="auto" selected>Auto</option>
  1308. <option value="light">Light</option>
  1309. <option value="dark">Dark</option>
  1310. </select>
  1311. </label> |</li>
  1312. </ul>
  1313. </div>
  1314. <div class="footer">
  1315. &copy;
  1316. <a href="../copyright.html">
  1317. Copyright
  1318. </a>
  1319. 2001-2024, Python Software Foundation.
  1320. <br />
  1321. This page is licensed under the Python Software Foundation License Version 2.
  1322. <br />
  1323. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  1324. <br />
  1325. See <a href="/license.html">History and License</a> for more information.<br />
  1326. <br />
  1327. The Python Software Foundation is a non-profit corporation.
  1328. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  1329. <br />
  1330. <br />
  1331. Last updated on Apr 09, 2024 (13:47 UTC).
  1332. <a href="/bugs.html">Found a bug</a>?
  1333. <br />
  1334. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  1335. </div>
  1336. </body>
  1337. </html>
上海开阖软件有限公司 沪ICP备12045867号-1