调整目录结构

This commit is contained in:
2025-10-23 18:57:37 +08:00
parent 6cf4d9cb03
commit 4966a659aa
2173 changed files with 4343 additions and 11 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,300 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta property="og:title" content="6. Editors and IDEs" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://docs.python.org/3/using/editors.html" />
<meta property="og:site_name" content="Python documentation" />
<meta property="og:description" content="There are a number of IDEs that support Python programming language. Many editors and IDEs provide syntax highlighting, debugging tools, and PEP 8 checks. Please go to Python Editors and Integrated..." />
<meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
<meta property="og:image:alt" content="Python documentation" />
<meta name="description" content="There are a number of IDEs that support Python programming language. Many editors and IDEs provide syntax highlighting, debugging tools, and PEP 8 checks. Please go to Python Editors and Integrated..." />
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />
<meta name="theme-color" content="#3776ab" />
<title>6. Editors and IDEs &#8212; Python 3.12.0 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?digest=b37c26da2f7529d09fe70b41c4b2133fe4931a90" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Python 3.12.0 documentation"
href="../_static/opensearch.xml"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="next" title="The Python Language Reference" href="../reference/index.html" />
<link rel="prev" title="5. Using Python on a Mac" href="mac.html" />
<link rel="canonical" href="https://docs.python.org/3/using/editors.html" />
<style>
@media only screen {
table.full-width-table {
width: 100%;
}
}
</style>
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
<script type="text/javascript" src="../_static/copybutton.js"></script>
<script type="text/javascript" src="../_static/menu.js"></script>
<script type="text/javascript" src="../_static/themetoggle.js"></script>
</head>
<body>
<div class="mobile-nav">
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
<nav class="nav-content" role="navigation">
<label for="menuToggler" class="toggler__label">
<span></span>
</label>
<span class="nav-items-wrapper">
<a href="https://www.python.org/" class="nav-logo">
<img src="../_static/py.svg" alt="Logo"/>
</a>
<span class="version_switcher_placeholder"></span>
<form role="search" class="search" action="../search.html" method="get">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
<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>
</svg>
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
<input type="submit" value="Go"/>
</form>
</span>
</nav>
<div class="menu-wrapper">
<nav class="menu" role="navigation" aria-label="main navigation">
<div class="language_switcher_placeholder"></div>
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="mac.html"
title="previous chapter"><span class="section-number">5. </span>Using Python on a Mac</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="../reference/index.html"
title="next chapter">The Python Language Reference</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/using/editors.rst"
rel="nofollow">Show Source
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="../reference/index.html" title="The Python Language Reference"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="mac.html" title="5. Using Python on a Mac"
accesskey="P">previous</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> &#187;</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.12.0 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Python Setup and Usage</a> &#187;</li>
<li class="nav-item nav-item-this"><a href=""><span class="section-number">6. </span>Editors and IDEs</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
<input type="submit" value="Go" />
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="editors-and-ides">
<span id="editors"></span><h1><span class="section-number">6. </span>Editors and IDEs<a class="headerlink" href="#editors-and-ides" title="Permalink to this headline"></a></h1>
<p>There are a number of IDEs that support Python programming language.
Many editors and IDEs provide syntax highlighting, debugging tools, and <span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-0008/"><strong>PEP 8</strong></a> checks.</p>
<p>Please go to <a class="reference external" href="https://wiki.python.org/moin/PythonEditors">Python Editors</a> and
<a class="reference external" href="https://wiki.python.org/moin/IntegratedDevelopmentEnvironments">Integrated Development Environments</a>
for a comprehensive list.</p>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="mac.html"
title="previous chapter"><span class="section-number">5. </span>Using Python on a Mac</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="../reference/index.html"
title="next chapter">The Python Language Reference</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/using/editors.rst"
rel="nofollow">Show Source
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="../reference/index.html" title="The Python Language Reference"
>next</a> |</li>
<li class="right" >
<a href="mac.html" title="5. Using Python on a Mac"
>previous</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> &#187;</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.12.0 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="index.html" >Python Setup and Usage</a> &#187;</li>
<li class="nav-item nav-item-this"><a href=""><span class="section-number">6. </span>Editors and IDEs</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
<input type="submit" value="Go" />
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="footer">
&copy; <a href="../copyright.html">Copyright</a> 2001-2023, Python Software Foundation.
<br />
This page is licensed under the Python Software Foundation License Version 2.
<br />
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
<br />
See <a href="/license.html">History and License</a> for more information.<br />
<br />
The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br />
<br />
Last updated on Oct 02, 2023.
<a href="/bugs.html">Found a bug</a>?
<br />
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.5.0.
</div>
</body>
</html>

View File

@@ -0,0 +1,433 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta property="og:title" content="Python Setup and Usage" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://docs.python.org/3/using/index.html" />
<meta property="og:site_name" content="Python documentation" />
<meta property="og:description" content="This part of the documentation is devoted to general information on the setup of the Python environment on different platforms, the invocation of the interpreter and things that make working with P..." />
<meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
<meta property="og:image:alt" content="Python documentation" />
<meta name="description" content="This part of the documentation is devoted to general information on the setup of the Python environment on different platforms, the invocation of the interpreter and things that make working with P..." />
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />
<meta name="theme-color" content="#3776ab" />
<title>Python Setup and Usage &#8212; Python 3.12.0 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?digest=b37c26da2f7529d09fe70b41c4b2133fe4931a90" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Python 3.12.0 documentation"
href="../_static/opensearch.xml"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="next" title="1. Command line and environment" href="cmdline.html" />
<link rel="prev" title="16. Appendix" href="../tutorial/appendix.html" />
<link rel="canonical" href="https://docs.python.org/3/using/index.html" />
<style>
@media only screen {
table.full-width-table {
width: 100%;
}
}
</style>
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
<script type="text/javascript" src="../_static/copybutton.js"></script>
<script type="text/javascript" src="../_static/menu.js"></script>
<script type="text/javascript" src="../_static/themetoggle.js"></script>
</head>
<body>
<div class="mobile-nav">
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
<nav class="nav-content" role="navigation">
<label for="menuToggler" class="toggler__label">
<span></span>
</label>
<span class="nav-items-wrapper">
<a href="https://www.python.org/" class="nav-logo">
<img src="../_static/py.svg" alt="Logo"/>
</a>
<span class="version_switcher_placeholder"></span>
<form role="search" class="search" action="../search.html" method="get">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
<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>
</svg>
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
<input type="submit" value="Go"/>
</form>
</span>
</nav>
<div class="menu-wrapper">
<nav class="menu" role="navigation" aria-label="main navigation">
<div class="language_switcher_placeholder"></div>
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="../tutorial/appendix.html"
title="previous chapter"><span class="section-number">16. </span>Appendix</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="cmdline.html"
title="next chapter"><span class="section-number">1. </span>Command line and environment</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/using/index.rst"
rel="nofollow">Show Source
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="cmdline.html" title="1. Command line and environment"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="../tutorial/appendix.html" title="16. Appendix"
accesskey="P">previous</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> &#187;</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.12.0 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-this"><a href="">Python Setup and Usage</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
<input type="submit" value="Go" />
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="python-setup-and-usage">
<span id="using-index"></span><h1>Python Setup and Usage<a class="headerlink" href="#python-setup-and-usage" title="Permalink to this headline"></a></h1>
<p>This part of the documentation is devoted to general information on the setup
of the Python environment on different platforms, the invocation of the
interpreter and things that make working with Python easier.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="cmdline.html">1. Command line and environment</a><ul>
<li class="toctree-l2"><a class="reference internal" href="cmdline.html#command-line">1.1. Command line</a><ul>
<li class="toctree-l3"><a class="reference internal" href="cmdline.html#interface-options">1.1.1. Interface options</a></li>
<li class="toctree-l3"><a class="reference internal" href="cmdline.html#generic-options">1.1.2. Generic options</a></li>
<li class="toctree-l3"><a class="reference internal" href="cmdline.html#miscellaneous-options">1.1.3. Miscellaneous options</a></li>
<li class="toctree-l3"><a class="reference internal" href="cmdline.html#options-you-shouldn-t-use">1.1.4. Options you shouldnt use</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="cmdline.html#environment-variables">1.2. Environment variables</a><ul>
<li class="toctree-l3"><a class="reference internal" href="cmdline.html#debug-mode-variables">1.2.1. Debug-mode variables</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="unix.html">2. Using Python on Unix platforms</a><ul>
<li class="toctree-l2"><a class="reference internal" href="unix.html#getting-and-installing-the-latest-version-of-python">2.1. Getting and installing the latest version of Python</a><ul>
<li class="toctree-l3"><a class="reference internal" href="unix.html#on-linux">2.1.1. On Linux</a></li>
<li class="toctree-l3"><a class="reference internal" href="unix.html#on-freebsd-and-openbsd">2.1.2. On FreeBSD and OpenBSD</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="unix.html#building-python">2.2. Building Python</a></li>
<li class="toctree-l2"><a class="reference internal" href="unix.html#python-related-paths-and-files">2.3. Python-related paths and files</a></li>
<li class="toctree-l2"><a class="reference internal" href="unix.html#miscellaneous">2.4. Miscellaneous</a></li>
<li class="toctree-l2"><a class="reference internal" href="unix.html#custom-openssl">2.5. Custom OpenSSL</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="configure.html">3. Configure Python</a><ul>
<li class="toctree-l2"><a class="reference internal" href="configure.html#build-requirements">3.1. Build Requirements</a></li>
<li class="toctree-l2"><a class="reference internal" href="configure.html#generated-files">3.2. Generated files</a></li>
<li class="toctree-l2"><a class="reference internal" href="configure.html#configure-options">3.3. Configure Options</a><ul>
<li class="toctree-l3"><a class="reference internal" href="configure.html#general-options">3.3.1. General Options</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#webassembly-options">3.3.2. WebAssembly Options</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#install-options">3.3.3. Install Options</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#performance-options">3.3.4. Performance options</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#python-debug-build">3.3.5. Python Debug Build</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#debug-options">3.3.6. Debug options</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#linker-options">3.3.7. Linker options</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#libraries-options">3.3.8. Libraries options</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#security-options">3.3.9. Security Options</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#macos-options">3.3.10. macOS Options</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#cross-compiling-options">3.3.11. Cross Compiling Options</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="configure.html#python-build-system">3.4. Python Build System</a><ul>
<li class="toctree-l3"><a class="reference internal" href="configure.html#main-files-of-the-build-system">3.4.1. Main files of the build system</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#main-build-steps">3.4.2. Main build steps</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#main-makefile-targets">3.4.3. Main Makefile targets</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#c-extensions">3.4.4. C extensions</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="configure.html#compiler-and-linker-flags">3.5. Compiler and linker flags</a><ul>
<li class="toctree-l3"><a class="reference internal" href="configure.html#preprocessor-flags">3.5.1. Preprocessor flags</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#compiler-flags">3.5.2. Compiler flags</a></li>
<li class="toctree-l3"><a class="reference internal" href="configure.html#linker-flags">3.5.3. Linker flags</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="windows.html">4. Using Python on Windows</a><ul>
<li class="toctree-l2"><a class="reference internal" href="windows.html#the-full-installer">4.1. The full installer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="windows.html#installation-steps">4.1.1. Installation steps</a></li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#removing-the-max-path-limitation">4.1.2. Removing the MAX_PATH Limitation</a></li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#installing-without-ui">4.1.3. Installing Without UI</a></li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#installing-without-downloading">4.1.4. Installing Without Downloading</a></li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#modifying-an-install">4.1.5. Modifying an install</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="windows.html#the-microsoft-store-package">4.2. The Microsoft Store package</a><ul>
<li class="toctree-l3"><a class="reference internal" href="windows.html#known-issues">4.2.1. Known issues</a><ul>
<li class="toctree-l4"><a class="reference internal" href="windows.html#redirection-of-local-data-registry-and-temporary-paths">4.2.1.1. Redirection of local data, registry, and temporary paths</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="windows.html#the-nuget-org-packages">4.3. The nuget.org packages</a></li>
<li class="toctree-l2"><a class="reference internal" href="windows.html#the-embeddable-package">4.4. The embeddable package</a><ul>
<li class="toctree-l3"><a class="reference internal" href="windows.html#python-application">4.4.1. Python Application</a></li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#embedding-python">4.4.2. Embedding Python</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="windows.html#alternative-bundles">4.5. Alternative bundles</a></li>
<li class="toctree-l2"><a class="reference internal" href="windows.html#configuring-python">4.6. Configuring Python</a><ul>
<li class="toctree-l3"><a class="reference internal" href="windows.html#excursus-setting-environment-variables">4.6.1. Excursus: Setting environment variables</a></li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#finding-the-python-executable">4.6.2. Finding the Python executable</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="windows.html#utf-8-mode">4.7. UTF-8 mode</a></li>
<li class="toctree-l2"><a class="reference internal" href="windows.html#python-launcher-for-windows">4.8. Python Launcher for Windows</a><ul>
<li class="toctree-l3"><a class="reference internal" href="windows.html#getting-started">4.8.1. Getting started</a><ul>
<li class="toctree-l4"><a class="reference internal" href="windows.html#from-the-command-line">4.8.1.1. From the command-line</a></li>
<li class="toctree-l4"><a class="reference internal" href="windows.html#virtual-environments">4.8.1.2. Virtual environments</a></li>
<li class="toctree-l4"><a class="reference internal" href="windows.html#from-a-script">4.8.1.3. From a script</a></li>
<li class="toctree-l4"><a class="reference internal" href="windows.html#from-file-associations">4.8.1.4. From file associations</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#shebang-lines">4.8.2. Shebang Lines</a></li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#arguments-in-shebang-lines">4.8.3. Arguments in shebang lines</a></li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#customization">4.8.4. Customization</a><ul>
<li class="toctree-l4"><a class="reference internal" href="windows.html#customization-via-ini-files">4.8.4.1. Customization via INI files</a></li>
<li class="toctree-l4"><a class="reference internal" href="windows.html#customizing-default-python-versions">4.8.4.2. Customizing default Python versions</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#diagnostics">4.8.5. Diagnostics</a></li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#dry-run">4.8.6. Dry Run</a></li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#install-on-demand">4.8.7. Install on demand</a></li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#return-codes">4.8.8. Return codes</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="windows.html#finding-modules">4.9. Finding modules</a></li>
<li class="toctree-l2"><a class="reference internal" href="windows.html#additional-modules">4.10. Additional modules</a><ul>
<li class="toctree-l3"><a class="reference internal" href="windows.html#pywin32">4.10.1. PyWin32</a></li>
<li class="toctree-l3"><a class="reference internal" href="windows.html#cx-freeze">4.10.2. cx_Freeze</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="windows.html#compiling-python-on-windows">4.11. Compiling Python on Windows</a></li>
<li class="toctree-l2"><a class="reference internal" href="windows.html#other-platforms">4.12. Other Platforms</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="mac.html">5. Using Python on a Mac</a><ul>
<li class="toctree-l2"><a class="reference internal" href="mac.html#getting-and-installing-macpython">5.1. Getting and Installing MacPython</a><ul>
<li class="toctree-l3"><a class="reference internal" href="mac.html#how-to-run-a-python-script">5.1.1. How to run a Python script</a></li>
<li class="toctree-l3"><a class="reference internal" href="mac.html#running-scripts-with-a-gui">5.1.2. Running scripts with a GUI</a></li>
<li class="toctree-l3"><a class="reference internal" href="mac.html#configuration">5.1.3. Configuration</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="mac.html#the-ide">5.2. The IDE</a></li>
<li class="toctree-l2"><a class="reference internal" href="mac.html#installing-additional-python-packages">5.3. Installing Additional Python Packages</a></li>
<li class="toctree-l2"><a class="reference internal" href="mac.html#gui-programming-on-the-mac">5.4. GUI Programming on the Mac</a></li>
<li class="toctree-l2"><a class="reference internal" href="mac.html#distributing-python-applications-on-the-mac">5.5. Distributing Python Applications on the Mac</a></li>
<li class="toctree-l2"><a class="reference internal" href="mac.html#other-resources">5.6. Other Resources</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="editors.html">6. Editors and IDEs</a></li>
</ul>
</div>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="../tutorial/appendix.html"
title="previous chapter"><span class="section-number">16. </span>Appendix</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="cmdline.html"
title="next chapter"><span class="section-number">1. </span>Command line and environment</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/using/index.rst"
rel="nofollow">Show Source
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="cmdline.html" title="1. Command line and environment"
>next</a> |</li>
<li class="right" >
<a href="../tutorial/appendix.html" title="16. Appendix"
>previous</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> &#187;</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.12.0 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-this"><a href="">Python Setup and Usage</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
<input type="submit" value="Go" />
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="footer">
&copy; <a href="../copyright.html">Copyright</a> 2001-2023, Python Software Foundation.
<br />
This page is licensed under the Python Software Foundation License Version 2.
<br />
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
<br />
See <a href="/license.html">History and License</a> for more information.<br />
<br />
The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br />
<br />
Last updated on Oct 02, 2023.
<a href="/bugs.html">Found a bug</a>?
<br />
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.5.0.
</div>
</body>
</html>

View File

@@ -0,0 +1,460 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta property="og:title" content="5. Using Python on a Mac" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://docs.python.org/3/using/mac.html" />
<meta property="og:site_name" content="Python documentation" />
<meta property="og:description" content="Author, Bob Savage < bobsavage@mac.com>,. Python on a Mac running macOS is in principle very similar to Python on any other Unix platform, but there are a number of additional features such as the ..." />
<meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
<meta property="og:image:alt" content="Python documentation" />
<meta name="description" content="Author, Bob Savage < bobsavage@mac.com>,. Python on a Mac running macOS is in principle very similar to Python on any other Unix platform, but there are a number of additional features such as the ..." />
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />
<meta name="theme-color" content="#3776ab" />
<title>5. Using Python on a Mac &#8212; Python 3.12.0 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?digest=b37c26da2f7529d09fe70b41c4b2133fe4931a90" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Python 3.12.0 documentation"
href="../_static/opensearch.xml"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="next" title="6. Editors and IDEs" href="editors.html" />
<link rel="prev" title="4. Using Python on Windows" href="windows.html" />
<link rel="canonical" href="https://docs.python.org/3/using/mac.html" />
<style>
@media only screen {
table.full-width-table {
width: 100%;
}
}
</style>
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
<script type="text/javascript" src="../_static/copybutton.js"></script>
<script type="text/javascript" src="../_static/menu.js"></script>
<script type="text/javascript" src="../_static/themetoggle.js"></script>
</head>
<body>
<div class="mobile-nav">
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
<nav class="nav-content" role="navigation">
<label for="menuToggler" class="toggler__label">
<span></span>
</label>
<span class="nav-items-wrapper">
<a href="https://www.python.org/" class="nav-logo">
<img src="../_static/py.svg" alt="Logo"/>
</a>
<span class="version_switcher_placeholder"></span>
<form role="search" class="search" action="../search.html" method="get">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
<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>
</svg>
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
<input type="submit" value="Go"/>
</form>
</span>
</nav>
<div class="menu-wrapper">
<nav class="menu" role="navigation" aria-label="main navigation">
<div class="language_switcher_placeholder"></div>
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label>
<div>
<h3><a href="../contents.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">5. Using Python on a Mac</a><ul>
<li><a class="reference internal" href="#getting-and-installing-macpython">5.1. Getting and Installing MacPython</a><ul>
<li><a class="reference internal" href="#how-to-run-a-python-script">5.1.1. How to run a Python script</a></li>
<li><a class="reference internal" href="#running-scripts-with-a-gui">5.1.2. Running scripts with a GUI</a></li>
<li><a class="reference internal" href="#configuration">5.1.3. Configuration</a></li>
</ul>
</li>
<li><a class="reference internal" href="#the-ide">5.2. The IDE</a></li>
<li><a class="reference internal" href="#installing-additional-python-packages">5.3. Installing Additional Python Packages</a></li>
<li><a class="reference internal" href="#gui-programming-on-the-mac">5.4. GUI Programming on the Mac</a></li>
<li><a class="reference internal" href="#distributing-python-applications-on-the-mac">5.5. Distributing Python Applications on the Mac</a></li>
<li><a class="reference internal" href="#other-resources">5.6. Other Resources</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="windows.html"
title="previous chapter"><span class="section-number">4. </span>Using Python on Windows</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="editors.html"
title="next chapter"><span class="section-number">6. </span>Editors and IDEs</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/using/mac.rst"
rel="nofollow">Show Source
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="editors.html" title="6. Editors and IDEs"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="windows.html" title="4. Using Python on Windows"
accesskey="P">previous</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> &#187;</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.12.0 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Python Setup and Usage</a> &#187;</li>
<li class="nav-item nav-item-this"><a href=""><span class="section-number">5. </span>Using Python on a Mac</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
<input type="submit" value="Go" />
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="using-python-on-a-mac">
<span id="using-on-mac"></span><h1><span class="section-number">5. </span>Using Python on a Mac<a class="headerlink" href="#using-python-on-a-mac" title="Permalink to this headline"></a></h1>
<dl class="field-list simple">
<dt class="field-odd">Author</dt>
<dd class="field-odd"><p>Bob Savage &lt;<a class="reference external" href="mailto:bobsavage&#37;&#52;&#48;mac&#46;com">bobsavage<span>&#64;</span>mac<span>&#46;</span>com</a>&gt;</p>
</dd>
</dl>
<p>Python on a Mac running macOS is in principle very similar to Python on
any other Unix platform, but there are a number of additional features such as
the IDE and the Package Manager that are worth pointing out.</p>
<section id="getting-and-installing-macpython">
<span id="getting-osx"></span><h2><span class="section-number">5.1. </span>Getting and Installing MacPython<a class="headerlink" href="#getting-and-installing-macpython" title="Permalink to this headline"></a></h2>
<p>macOS used to come with Python 2.7 pre-installed between versions
10.8 and <a class="reference external" href="https://developer.apple.com/documentation/macos-release-notes/macos-12_3-release-notes#Python">12.3</a>.
You are invited to install the most recent version of Python 3 from the Python
website (<a class="reference external" href="https://www.python.org">https://www.python.org</a>). A current “universal binary” build of Python,
which runs natively on the Macs new Intel and legacy PPC CPUs, is available
there.</p>
<p>What you get after installing is a number of things:</p>
<ul class="simple">
<li><p>A <code class="file docutils literal notranslate"><span class="pre">Python</span> <span class="pre">3.12</span></code> folder in your <code class="file docutils literal notranslate"><span class="pre">Applications</span></code> folder. In here
you find IDLE, the development environment that is a standard part of official
Python distributions; and PythonLauncher, which handles double-clicking Python
scripts from the Finder.</p></li>
<li><p>A framework <code class="file docutils literal notranslate"><span class="pre">/Library/Frameworks/Python.framework</span></code>, which includes the
Python executable and libraries. The installer adds this location to your shell
path. To uninstall MacPython, you can simply remove these three things. A
symlink to the Python executable is placed in /usr/local/bin/.</p></li>
</ul>
<p>The Apple-provided build of Python is installed in
<code class="file docutils literal notranslate"><span class="pre">/System/Library/Frameworks/Python.framework</span></code> and <code class="file docutils literal notranslate"><span class="pre">/usr/bin/python</span></code>,
respectively. You should never modify or delete these, as they are
Apple-controlled and are used by Apple- or third-party software. Remember that
if you choose to install a newer Python version from python.org, you will have
two different but functional Python installations on your computer, so it will
be important that your paths and usages are consistent with what you want to do.</p>
<p>IDLE includes a help menu that allows you to access Python documentation. If you
are completely new to Python you should start reading the tutorial introduction
in that document.</p>
<p>If you are familiar with Python on other Unix platforms you should read the
section on running Python scripts from the Unix shell.</p>
<section id="how-to-run-a-python-script">
<h3><span class="section-number">5.1.1. </span>How to run a Python script<a class="headerlink" href="#how-to-run-a-python-script" title="Permalink to this headline"></a></h3>
<p>Your best way to get started with Python on macOS is through the IDLE
integrated development environment, see section <a class="reference internal" href="#ide"><span class="std std-ref">The IDE</span></a> and use the Help menu
when the IDE is running.</p>
<p>If you want to run Python scripts from the Terminal window command line or from
the Finder you first need an editor to create your script. macOS comes with a
number of standard Unix command line editors, <strong class="program">vim</strong> and
<strong class="program">emacs</strong> among them. If you want a more Mac-like editor,
<strong class="program">BBEdit</strong> or <strong class="program">TextWrangler</strong> from Bare Bones Software (see
<a class="reference external" href="http://www.barebones.com/products/bbedit/index.html">http://www.barebones.com/products/bbedit/index.html</a>) are good choices, as is
<strong class="program">TextMate</strong> (see <a class="reference external" href="https://macromates.com/">https://macromates.com/</a>). Other editors include
<strong class="program">Gvim</strong> (<a class="reference external" href="https://macvim.org/macvim/">https://macvim.org/macvim/</a>) and <strong class="program">Aquamacs</strong>
(<a class="reference external" href="http://aquamacs.org/">http://aquamacs.org/</a>).</p>
<p>To run your script from the Terminal window you must make sure that
<code class="file docutils literal notranslate"><span class="pre">/usr/local/bin</span></code> is in your shell search path.</p>
<p>To run your script from the Finder you have two options:</p>
<ul class="simple">
<li><p>Drag it to <strong class="program">PythonLauncher</strong></p></li>
<li><p>Select <strong class="program">PythonLauncher</strong> as the default application to open your
script (or any .py script) through the finder Info window and double-click it.
<strong class="program">PythonLauncher</strong> has various preferences to control how your script is
launched. Option-dragging allows you to change these for one invocation, or use
its Preferences menu to change things globally.</p></li>
</ul>
</section>
<section id="running-scripts-with-a-gui">
<span id="osx-gui-scripts"></span><h3><span class="section-number">5.1.2. </span>Running scripts with a GUI<a class="headerlink" href="#running-scripts-with-a-gui" title="Permalink to this headline"></a></h3>
<p>With older versions of Python, there is one macOS quirk that you need to be
aware of: programs that talk to the Aqua window manager (in other words,
anything that has a GUI) need to be run in a special way. Use <strong class="program">pythonw</strong>
instead of <strong class="program">python</strong> to start such scripts.</p>
<p>With Python 3.9, you can use either <strong class="program">python</strong> or <strong class="program">pythonw</strong>.</p>
</section>
<section id="configuration">
<h3><span class="section-number">5.1.3. </span>Configuration<a class="headerlink" href="#configuration" title="Permalink to this headline"></a></h3>
<p>Python on macOS honors all standard Unix environment variables such as
<span class="target" id="index-0"></span><a class="reference internal" href="cmdline.html#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPATH</span></code></a>, but setting these variables for programs started from the
Finder is non-standard as the Finder does not read your <code class="file docutils literal notranslate"><span class="pre">.profile</span></code> or
<code class="file docutils literal notranslate"><span class="pre">.cshrc</span></code> at startup. You need to create a file
<code class="file docutils literal notranslate"><span class="pre">~/.MacOSX/environment.plist</span></code>. See Apples Technical Document QA1067 for
details.</p>
<p>For more information on installation Python packages in MacPython, see section
<a class="reference internal" href="#mac-package-manager"><span class="std std-ref">Installing Additional Python Packages</span></a>.</p>
</section>
</section>
<section id="the-ide">
<span id="ide"></span><h2><span class="section-number">5.2. </span>The IDE<a class="headerlink" href="#the-ide" title="Permalink to this headline"></a></h2>
<p>MacPython ships with the standard IDLE development environment. A good
introduction to using IDLE can be found at
<a class="reference external" href="http://www.hashcollision.org/hkn/python/idle_intro/index.html">http://www.hashcollision.org/hkn/python/idle_intro/index.html</a>.</p>
</section>
<section id="installing-additional-python-packages">
<span id="mac-package-manager"></span><h2><span class="section-number">5.3. </span>Installing Additional Python Packages<a class="headerlink" href="#installing-additional-python-packages" title="Permalink to this headline"></a></h2>
<p>This section has moved to the <a class="reference external" href="https://packaging.python.org/en/latest/tutorials/installing-packages/">Python Packaging User Guide</a>.</p>
</section>
<section id="gui-programming-on-the-mac">
<h2><span class="section-number">5.4. </span>GUI Programming on the Mac<a class="headerlink" href="#gui-programming-on-the-mac" title="Permalink to this headline"></a></h2>
<p>There are several options for building GUI applications on the Mac with Python.</p>
<p><em>PyObjC</em> is a Python binding to Apples Objective-C/Cocoa framework, which is
the foundation of most modern Mac development. Information on PyObjC is
available from <a class="reference external" href="https://pypi.org/project/pyobjc/">https://pypi.org/project/pyobjc/</a>.</p>
<p>The standard Python GUI toolkit is <a class="reference internal" href="../library/tkinter.html#module-tkinter" title="tkinter: Interface to Tcl/Tk for graphical user interfaces"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code></a>, based on the cross-platform
Tk toolkit (<a class="reference external" href="https://www.tcl.tk">https://www.tcl.tk</a>). An Aqua-native version of Tk is bundled with
macOS by Apple, and the latest version can be downloaded and installed from
<a class="reference external" href="https://www.activestate.com">https://www.activestate.com</a>; it can also be built from source.</p>
<p><em>wxPython</em> is another popular cross-platform GUI toolkit that runs natively on
macOS. Packages and documentation are available from <a class="reference external" href="https://www.wxpython.org">https://www.wxpython.org</a>.</p>
<p><em>PyQt</em> is another popular cross-platform GUI toolkit that runs natively on
macOS. More information can be found at
<a class="reference external" href="https://riverbankcomputing.com/software/pyqt/intro">https://riverbankcomputing.com/software/pyqt/intro</a>.</p>
</section>
<section id="distributing-python-applications-on-the-mac">
<h2><span class="section-number">5.5. </span>Distributing Python Applications on the Mac<a class="headerlink" href="#distributing-python-applications-on-the-mac" title="Permalink to this headline"></a></h2>
<p>The standard tool for deploying standalone Python applications on the Mac is
<strong class="program">py2app</strong>. More information on installing and using py2app can be found
at <a class="reference external" href="https://pypi.org/project/py2app/">https://pypi.org/project/py2app/</a>.</p>
</section>
<section id="other-resources">
<h2><span class="section-number">5.6. </span>Other Resources<a class="headerlink" href="#other-resources" title="Permalink to this headline"></a></h2>
<p>The MacPython mailing list is an excellent support resource for Python users and
developers on the Mac:</p>
<p><a class="reference external" href="https://www.python.org/community/sigs/current/pythonmac-sig/">https://www.python.org/community/sigs/current/pythonmac-sig/</a></p>
<p>Another useful resource is the MacPython wiki:</p>
<p><a class="reference external" href="https://wiki.python.org/moin/MacPython">https://wiki.python.org/moin/MacPython</a></p>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div>
<h3><a href="../contents.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">5. Using Python on a Mac</a><ul>
<li><a class="reference internal" href="#getting-and-installing-macpython">5.1. Getting and Installing MacPython</a><ul>
<li><a class="reference internal" href="#how-to-run-a-python-script">5.1.1. How to run a Python script</a></li>
<li><a class="reference internal" href="#running-scripts-with-a-gui">5.1.2. Running scripts with a GUI</a></li>
<li><a class="reference internal" href="#configuration">5.1.3. Configuration</a></li>
</ul>
</li>
<li><a class="reference internal" href="#the-ide">5.2. The IDE</a></li>
<li><a class="reference internal" href="#installing-additional-python-packages">5.3. Installing Additional Python Packages</a></li>
<li><a class="reference internal" href="#gui-programming-on-the-mac">5.4. GUI Programming on the Mac</a></li>
<li><a class="reference internal" href="#distributing-python-applications-on-the-mac">5.5. Distributing Python Applications on the Mac</a></li>
<li><a class="reference internal" href="#other-resources">5.6. Other Resources</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="windows.html"
title="previous chapter"><span class="section-number">4. </span>Using Python on Windows</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="editors.html"
title="next chapter"><span class="section-number">6. </span>Editors and IDEs</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/using/mac.rst"
rel="nofollow">Show Source
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="editors.html" title="6. Editors and IDEs"
>next</a> |</li>
<li class="right" >
<a href="windows.html" title="4. Using Python on Windows"
>previous</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> &#187;</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.12.0 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="index.html" >Python Setup and Usage</a> &#187;</li>
<li class="nav-item nav-item-this"><a href=""><span class="section-number">5. </span>Using Python on a Mac</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
<input type="submit" value="Go" />
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="footer">
&copy; <a href="../copyright.html">Copyright</a> 2001-2023, Python Software Foundation.
<br />
This page is licensed under the Python Software Foundation License Version 2.
<br />
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
<br />
See <a href="/license.html">History and License</a> for more information.<br />
<br />
The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br />
<br />
Last updated on Oct 02, 2023.
<a href="/bugs.html">Found a bug</a>?
<br />
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.5.0.
</div>
</body>
</html>

View File

@@ -0,0 +1,503 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta property="og:title" content="2. Using Python on Unix platforms" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://docs.python.org/3/using/unix.html" />
<meta property="og:site_name" content="Python documentation" />
<meta property="og:description" content="Getting and installing the latest version of Python: On Linux: Python comes preinstalled on most Linux distributions, and is available as a package on all others. However there are certain features..." />
<meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
<meta property="og:image:alt" content="Python documentation" />
<meta name="description" content="Getting and installing the latest version of Python: On Linux: Python comes preinstalled on most Linux distributions, and is available as a package on all others. However there are certain features..." />
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />
<meta name="theme-color" content="#3776ab" />
<title>2. Using Python on Unix platforms &#8212; Python 3.12.0 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?digest=b37c26da2f7529d09fe70b41c4b2133fe4931a90" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Python 3.12.0 documentation"
href="../_static/opensearch.xml"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="next" title="3. Configure Python" href="configure.html" />
<link rel="prev" title="1. Command line and environment" href="cmdline.html" />
<link rel="canonical" href="https://docs.python.org/3/using/unix.html" />
<style>
@media only screen {
table.full-width-table {
width: 100%;
}
}
</style>
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
<script type="text/javascript" src="../_static/copybutton.js"></script>
<script type="text/javascript" src="../_static/menu.js"></script>
<script type="text/javascript" src="../_static/themetoggle.js"></script>
</head>
<body>
<div class="mobile-nav">
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
<nav class="nav-content" role="navigation">
<label for="menuToggler" class="toggler__label">
<span></span>
</label>
<span class="nav-items-wrapper">
<a href="https://www.python.org/" class="nav-logo">
<img src="../_static/py.svg" alt="Logo"/>
</a>
<span class="version_switcher_placeholder"></span>
<form role="search" class="search" action="../search.html" method="get">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
<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>
</svg>
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
<input type="submit" value="Go"/>
</form>
</span>
</nav>
<div class="menu-wrapper">
<nav class="menu" role="navigation" aria-label="main navigation">
<div class="language_switcher_placeholder"></div>
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label>
<div>
<h3><a href="../contents.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">2. Using Python on Unix platforms</a><ul>
<li><a class="reference internal" href="#getting-and-installing-the-latest-version-of-python">2.1. Getting and installing the latest version of Python</a><ul>
<li><a class="reference internal" href="#on-linux">2.1.1. On Linux</a></li>
<li><a class="reference internal" href="#on-freebsd-and-openbsd">2.1.2. On FreeBSD and OpenBSD</a></li>
</ul>
</li>
<li><a class="reference internal" href="#building-python">2.2. Building Python</a></li>
<li><a class="reference internal" href="#python-related-paths-and-files">2.3. Python-related paths and files</a></li>
<li><a class="reference internal" href="#miscellaneous">2.4. Miscellaneous</a></li>
<li><a class="reference internal" href="#custom-openssl">2.5. Custom OpenSSL</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="cmdline.html"
title="previous chapter"><span class="section-number">1. </span>Command line and environment</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="configure.html"
title="next chapter"><span class="section-number">3. </span>Configure Python</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/using/unix.rst"
rel="nofollow">Show Source
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="configure.html" title="3. Configure Python"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="cmdline.html" title="1. Command line and environment"
accesskey="P">previous</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> &#187;</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.12.0 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Python Setup and Usage</a> &#187;</li>
<li class="nav-item nav-item-this"><a href=""><span class="section-number">2. </span>Using Python on Unix platforms</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
<input type="submit" value="Go" />
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="using-python-on-unix-platforms">
<span id="using-on-unix"></span><h1><span class="section-number">2. </span>Using Python on Unix platforms<a class="headerlink" href="#using-python-on-unix-platforms" title="Permalink to this headline"></a></h1>
<section id="getting-and-installing-the-latest-version-of-python">
<h2><span class="section-number">2.1. </span>Getting and installing the latest version of Python<a class="headerlink" href="#getting-and-installing-the-latest-version-of-python" title="Permalink to this headline"></a></h2>
<section id="on-linux">
<h3><span class="section-number">2.1.1. </span>On Linux<a class="headerlink" href="#on-linux" title="Permalink to this headline"></a></h3>
<p>Python comes preinstalled on most Linux distributions, and is available as a
package on all others. However there are certain features you might want to use
that are not available on your distros package. You can easily compile the
latest version of Python from source.</p>
<p>In the event that Python doesnt come preinstalled and isnt in the repositories as
well, you can easily make packages for your own distro. Have a look at the
following links:</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference external" href="https://www.debian.org/doc/manuals/maint-guide/first.en.html">https://www.debian.org/doc/manuals/maint-guide/first.en.html</a></dt><dd><p>for Debian users</p>
</dd>
<dt><a class="reference external" href="https://en.opensuse.org/Portal:Packaging">https://en.opensuse.org/Portal:Packaging</a></dt><dd><p>for OpenSuse users</p>
</dd>
<dt><a class="reference external" href="https://docs.fedoraproject.org/en-US/package-maintainers/Packaging_Tutorial_GNU_Hello/">https://docs.fedoraproject.org/en-US/package-maintainers/Packaging_Tutorial_GNU_Hello/</a></dt><dd><p>for Fedora users</p>
</dd>
<dt><a class="reference external" href="https://slackbook.org/html/package-management-making-packages.html">https://slackbook.org/html/package-management-making-packages.html</a></dt><dd><p>for Slackware users</p>
</dd>
</dl>
</div>
</section>
<section id="on-freebsd-and-openbsd">
<h3><span class="section-number">2.1.2. </span>On FreeBSD and OpenBSD<a class="headerlink" href="#on-freebsd-and-openbsd" title="Permalink to this headline"></a></h3>
<ul>
<li><p>FreeBSD users, to add the package use:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>pkg<span class="w"> </span>install<span class="w"> </span>python3
</pre></div>
</div>
</li>
<li><p>OpenBSD users, to add the package use:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>pkg_add<span class="w"> </span>-r<span class="w"> </span>python
pkg_add<span class="w"> </span>ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/&lt;insert<span class="w"> </span>your<span class="w"> </span>architecture<span class="w"> </span>here&gt;/python-&lt;version&gt;.tgz
</pre></div>
</div>
<p>For example i386 users get the 2.5.1 version of Python using:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>pkg_add<span class="w"> </span>ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/python-2.5.1p2.tgz
</pre></div>
</div>
</li>
</ul>
</section>
</section>
<section id="building-python">
<span id="building-python-on-unix"></span><h2><span class="section-number">2.2. </span>Building Python<a class="headerlink" href="#building-python" title="Permalink to this headline"></a></h2>
<p>If you want to compile CPython yourself, first thing you should do is get the
<a class="reference external" href="https://www.python.org/downloads/source/">source</a>. You can download either the
latest releases source or just grab a fresh <a class="reference external" href="https://devguide.python.org/setup/#get-the-source-code">clone</a>. (If you want
to contribute patches, you will need a clone.)</p>
<p>The build process consists of the usual commands:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>./configure
make
make<span class="w"> </span>install
</pre></div>
</div>
<p><a class="reference internal" href="configure.html#configure-options"><span class="std std-ref">Configuration options</span></a> and caveats for specific Unix
platforms are extensively documented in the <a class="reference external" href="https://github.com/python/cpython/tree/3.12/README.rst">README.rst</a> file in the
root of the Python source tree.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p><code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">install</span></code> can overwrite or masquerade the <code class="file docutils literal notranslate"><span class="pre">python3</span></code> binary.
<code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">altinstall</span></code> is therefore recommended instead of <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">install</span></code>
since it only installs <code class="file docutils literal notranslate"><em><span class="pre">exec_prefix</span></em><span class="pre">/bin/python</span><em><span class="pre">version</span></em></code>.</p>
</div>
</section>
<section id="python-related-paths-and-files">
<h2><span class="section-number">2.3. </span>Python-related paths and files<a class="headerlink" href="#python-related-paths-and-files" title="Permalink to this headline"></a></h2>
<p>These are subject to difference depending on local installation conventions;
<a class="reference internal" href="configure.html#cmdoption-prefix"><code class="xref std std-option docutils literal notranslate"><span class="pre">prefix</span></code></a> and <a class="reference internal" href="configure.html#cmdoption-exec-prefix"><code class="xref std std-option docutils literal notranslate"><span class="pre">exec_prefix</span></code></a>
are installation-dependent and should be interpreted as for GNU software; they
may be the same.</p>
<p>For example, on most Linux systems, the default for both is <code class="file docutils literal notranslate"><span class="pre">/usr</span></code>.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 53%" />
<col style="width: 47%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>File/directory</p></th>
<th class="head"><p>Meaning</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="file docutils literal notranslate"><em><span class="pre">exec_prefix</span></em><span class="pre">/bin/python3</span></code></p></td>
<td><p>Recommended location of the interpreter.</p></td>
</tr>
<tr class="row-odd"><td><p><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>,
<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></p></td>
<td><p>Recommended locations of the directories
containing the standard modules.</p></td>
</tr>
<tr class="row-even"><td><p><code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em><span class="pre">/include/python</span><em><span class="pre">version</span></em></code>,
<code class="file docutils literal notranslate"><em><span class="pre">exec_prefix</span></em><span class="pre">/include/python</span><em><span class="pre">version</span></em></code></p></td>
<td><p>Recommended locations of the directories
containing the include files needed for
developing Python extensions and
embedding the interpreter.</p></td>
</tr>
</tbody>
</table>
</section>
<section id="miscellaneous">
<h2><span class="section-number">2.4. </span>Miscellaneous<a class="headerlink" href="#miscellaneous" title="Permalink to this headline"></a></h2>
<p>To easily use Python scripts on Unix, you need to make them executable,
e.g. with</p>
<div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>chmod<span class="w"> </span>+x<span class="w"> </span>script
</pre></div>
</div>
<p>and put an appropriate Shebang line at the top of the script. A good choice is
usually</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="ch">#!/usr/bin/env python3</span>
</pre></div>
</div>
<p>which searches for the Python interpreter in the whole <span class="target" id="index-0"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PATH</span></code>. However,
some Unices may not have the <strong class="program">env</strong> command, so you may need to hardcode
<code class="docutils literal notranslate"><span class="pre">/usr/bin/python3</span></code> as the interpreter path.</p>
<p>To use shell commands in your Python scripts, look at the <a class="reference internal" href="../library/subprocess.html#module-subprocess" title="subprocess: Subprocess management."><code class="xref py py-mod docutils literal notranslate"><span class="pre">subprocess</span></code></a> module.</p>
</section>
<section id="custom-openssl">
<span id="unix-custom-openssl"></span><h2><span class="section-number">2.5. </span>Custom OpenSSL<a class="headerlink" href="#custom-openssl" title="Permalink to this headline"></a></h2>
<ol class="arabic">
<li><p>To use your vendors OpenSSL configuration and system trust store, locate
the directory with <code class="docutils literal notranslate"><span class="pre">openssl.cnf</span></code> file or symlink in <code class="docutils literal notranslate"><span class="pre">/etc</span></code>. On most
distribution the file is either in <code class="docutils literal notranslate"><span class="pre">/etc/ssl</span></code> or <code class="docutils literal notranslate"><span class="pre">/etc/pki/tls</span></code>. The
directory should also contain a <code class="docutils literal notranslate"><span class="pre">cert.pem</span></code> file and/or a <code class="docutils literal notranslate"><span class="pre">certs</span></code>
directory.</p>
<div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>find<span class="w"> </span>/etc/<span class="w"> </span>-name<span class="w"> </span>openssl.cnf<span class="w"> </span>-printf<span class="w"> </span><span class="s2">&quot;%h\n&quot;</span>
<span class="go">/etc/ssl</span>
</pre></div>
</div>
</li>
<li><p>Download, build, and install OpenSSL. Make sure you use <code class="docutils literal notranslate"><span class="pre">install_sw</span></code> and
not <code class="docutils literal notranslate"><span class="pre">install</span></code>. The <code class="docutils literal notranslate"><span class="pre">install_sw</span></code> target does not override
<code class="docutils literal notranslate"><span class="pre">openssl.cnf</span></code>.</p>
<div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>curl<span class="w"> </span>-O<span class="w"> </span>https://www.openssl.org/source/openssl-VERSION.tar.gz
<span class="gp">$ </span>tar<span class="w"> </span>xzf<span class="w"> </span>openssl-VERSION
<span class="gp">$ </span><span class="nb">pushd</span><span class="w"> </span>openssl-VERSION
<span class="gp">$ </span>./config<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--prefix<span class="o">=</span>/usr/local/custom-openssl<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--libdir<span class="o">=</span>lib<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--openssldir<span class="o">=</span>/etc/ssl
<span class="gp">$ </span>make<span class="w"> </span>-j1<span class="w"> </span>depend
<span class="gp">$ </span>make<span class="w"> </span>-j8
<span class="gp">$ </span>make<span class="w"> </span>install_sw
<span class="gp">$ </span><span class="nb">popd</span>
</pre></div>
</div>
</li>
<li><p>Build Python with custom OpenSSL
(see the configure <code class="docutils literal notranslate"><span class="pre">--with-openssl</span></code> and <code class="docutils literal notranslate"><span class="pre">--with-openssl-rpath</span></code> options)</p>
<div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span><span class="nb">pushd</span><span class="w"> </span>python-3.x.x
<span class="gp">$ </span>./configure<span class="w"> </span>-C<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--with-openssl<span class="o">=</span>/usr/local/custom-openssl<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--with-openssl-rpath<span class="o">=</span>auto<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--prefix<span class="o">=</span>/usr/local/python-3.x.x
<span class="gp">$ </span>make<span class="w"> </span>-j8
<span class="gp">$ </span>make<span class="w"> </span>altinstall
</pre></div>
</div>
</li>
</ol>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Patch releases of OpenSSL have a backwards compatible ABI. You dont need
to recompile Python to update OpenSSL. Its sufficient to replace the
custom OpenSSL installation with a newer version.</p>
</div>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div>
<h3><a href="../contents.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">2. Using Python on Unix platforms</a><ul>
<li><a class="reference internal" href="#getting-and-installing-the-latest-version-of-python">2.1. Getting and installing the latest version of Python</a><ul>
<li><a class="reference internal" href="#on-linux">2.1.1. On Linux</a></li>
<li><a class="reference internal" href="#on-freebsd-and-openbsd">2.1.2. On FreeBSD and OpenBSD</a></li>
</ul>
</li>
<li><a class="reference internal" href="#building-python">2.2. Building Python</a></li>
<li><a class="reference internal" href="#python-related-paths-and-files">2.3. Python-related paths and files</a></li>
<li><a class="reference internal" href="#miscellaneous">2.4. Miscellaneous</a></li>
<li><a class="reference internal" href="#custom-openssl">2.5. Custom OpenSSL</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="cmdline.html"
title="previous chapter"><span class="section-number">1. </span>Command line and environment</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="configure.html"
title="next chapter"><span class="section-number">3. </span>Configure Python</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li>
<a href="https://github.com/python/cpython/blob/main/Doc/using/unix.rst"
rel="nofollow">Show Source
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="configure.html" title="3. Configure Python"
>next</a> |</li>
<li class="right" >
<a href="cmdline.html" title="1. Command line and environment"
>previous</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> &#187;</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.12.0 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="index.html" >Python Setup and Usage</a> &#187;</li>
<li class="nav-item nav-item-this"><a href=""><span class="section-number">2. </span>Using Python on Unix platforms</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
<input type="submit" value="Go" />
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="footer">
&copy; <a href="../copyright.html">Copyright</a> 2001-2023, Python Software Foundation.
<br />
This page is licensed under the Python Software Foundation License Version 2.
<br />
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
<br />
See <a href="/license.html">History and License</a> for more information.<br />
<br />
The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br />
<br />
Last updated on Oct 02, 2023.
<a href="/bugs.html">Found a bug</a>?
<br />
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.5.0.
</div>
</body>
</html>

File diff suppressed because it is too large Load Diff