508 lines
32 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:title" content="12. Virtual Environments and Packages" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://docs.python.org/3/tutorial/venv.html" />
<meta property="og:site_name" content="Python documentation" />
<meta property="og:description" content="Introduction: Python applications will often use packages and modules that dont come as part of the standard library. Applications will sometimes need a specific version of a library, because 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="Introduction: Python applications will often use packages and modules that dont come as part of the standard library. Applications will sometimes need a specific version of a library, because the ..." />
<meta property="og:image:width" content="200">
<meta property="og:image:height" content="200">
<meta name="theme-color" content="#3776ab">
<title>12. Virtual Environments and Packages &#8212; Python 3.13.3 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=23252803" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />
<script src="../_static/documentation_options.js?v=5d57ca2d"></script>
<script src="../_static/doctools.js?v=9bcbadda"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Python 3.13.3 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="13. What Now?" href="whatnow.html" />
<link rel="prev" title="11. Brief Tour of the Standard Library — Part II" href="stdlib2.html" />
<link rel="canonical" href="https://docs.python.org/3/tutorial/venv.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/search-focus.js"></script>
<script type="text/javascript" src="../_static/themetoggle.js"></script>
<script type="text/javascript" src="../_static/rtd_switcher.js"></script>
<meta name="readthedocs-addons-api-version" content="1">
</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="Python 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="#">12. Virtual Environments and Packages</a><ul>
<li><a class="reference internal" href="#introduction">12.1. Introduction</a></li>
<li><a class="reference internal" href="#creating-virtual-environments">12.2. Creating Virtual Environments</a></li>
<li><a class="reference internal" href="#managing-packages-with-pip">12.3. Managing Packages with pip</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="stdlib2.html"
title="previous chapter"><span class="section-number">11. </span>Brief Tour of the Standard Library — Part II</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="whatnow.html"
title="next chapter"><span class="section-number">13. </span>What Now?</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/tutorial/venv.rst"
rel="nofollow">Show Source
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="related" role="navigation" aria-label="Related">
<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="whatnow.html" title="13. What Now?"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="stdlib2.html" title="11. Brief Tour of the Standard Library — Part II"
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.13.3 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">The Python Tutorial</a> &#187;</li>
<li class="nav-item nav-item-this"><a href=""><span class="section-number">12. </span>Virtual Environments and Packages</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" id="search-box" />
<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="virtual-environments-and-packages">
<span id="tut-venv"></span><h1><span class="section-number">12. </span>Virtual Environments and Packages<a class="headerlink" href="#virtual-environments-and-packages" title="Link to this heading"></a></h1>
<section id="introduction">
<h2><span class="section-number">12.1. </span>Introduction<a class="headerlink" href="#introduction" title="Link to this heading"></a></h2>
<p>Python applications will often use packages and modules that dont
come as part of the standard library. Applications will sometimes
need a specific version of a library, because the application may
require that a particular bug has been fixed or the application may be
written using an obsolete version of the librarys interface.</p>
<p>This means it may not be possible for one Python installation to meet
the requirements of every application. If application A needs version
1.0 of a particular module but application B needs version 2.0, then
the requirements are in conflict and installing either version 1.0 or 2.0
will leave one application unable to run.</p>
<p>The solution for this problem is to create a <a class="reference internal" href="../glossary.html#term-virtual-environment"><span class="xref std std-term">virtual environment</span></a>, a
self-contained directory tree that contains a Python installation for a
particular version of Python, plus a number of additional packages.</p>
<p>Different applications can then use different virtual environments.
To resolve the earlier example of conflicting requirements,
application A can have its own virtual environment with version 1.0
installed while application B has another virtual environment with version 2.0.
If application B requires a library be upgraded to version 3.0, this will
not affect application As environment.</p>
</section>
<section id="creating-virtual-environments">
<h2><span class="section-number">12.2. </span>Creating Virtual Environments<a class="headerlink" href="#creating-virtual-environments" title="Link to this heading"></a></h2>
<p>The module used to create and manage virtual environments is called
<a class="reference internal" href="../library/venv.html#module-venv" title="venv: Creation of virtual environments."><code class="xref py py-mod docutils literal notranslate"><span class="pre">venv</span></code></a>. <a class="reference internal" href="../library/venv.html#module-venv" title="venv: Creation of virtual environments."><code class="xref py py-mod docutils literal notranslate"><span class="pre">venv</span></code></a> will install the Python version from which
the command was run (as reported by the <a class="reference internal" href="../using/cmdline.html#cmdoption-version"><code class="xref std std-option docutils literal notranslate"><span class="pre">--version</span></code></a> option).
For instance, executing the command with <code class="docutils literal notranslate"><span class="pre">python3.12</span></code> will install
version 3.12.</p>
<p>To create a virtual environment, decide upon a directory where you want to
place it, and run the <a class="reference internal" href="../library/venv.html#module-venv" title="venv: Creation of virtual environments."><code class="xref py py-mod docutils literal notranslate"><span class="pre">venv</span></code></a> module as a script with the directory path:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="o">-</span><span class="n">m</span> <span class="n">venv</span> <span class="n">tutorial</span><span class="o">-</span><span class="n">env</span>
</pre></div>
</div>
<p>This will create the <code class="docutils literal notranslate"><span class="pre">tutorial-env</span></code> directory if it doesnt exist,
and also create directories inside it containing a copy of the Python
interpreter and various supporting files.</p>
<p>A common directory location for a virtual environment is <code class="docutils literal notranslate"><span class="pre">.venv</span></code>.
This name keeps the directory typically hidden in your shell and thus
out of the way while giving it a name that explains why the directory
exists. It also prevents clashing with <code class="docutils literal notranslate"><span class="pre">.env</span></code> environment variable
definition files that some tooling supports.</p>
<p>Once youve created a virtual environment, you may activate it.</p>
<p>On Windows, run:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">tutorial</span><span class="o">-</span><span class="n">env</span>\<span class="n">Scripts</span>\<span class="n">activate</span>
</pre></div>
</div>
<p>On Unix or MacOS, run:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">source</span> <span class="n">tutorial</span><span class="o">-</span><span class="n">env</span><span class="o">/</span><span class="nb">bin</span><span class="o">/</span><span class="n">activate</span>
</pre></div>
</div>
<p>(This script is written for the bash shell. If you use the
<strong class="program">csh</strong> or <strong class="program">fish</strong> shells, there are alternate
<code class="docutils literal notranslate"><span class="pre">activate.csh</span></code> and <code class="docutils literal notranslate"><span class="pre">activate.fish</span></code> scripts you should use
instead.)</p>
<p>Activating the virtual environment will change your shells prompt to show what
virtual environment youre using, and modify the environment so that running
<code class="docutils literal notranslate"><span class="pre">python</span></code> will get you that particular version and installation of Python.
For example:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$<span class="w"> </span><span class="nb">source</span><span class="w"> </span>~/envs/tutorial-env/bin/activate
<span class="o">(</span>tutorial-env<span class="o">)</span><span class="w"> </span>$<span class="w"> </span>python
Python<span class="w"> </span><span class="m">3</span>.5.1<span class="w"> </span><span class="o">(</span>default,<span class="w"> </span>May<span class="w"> </span><span class="m">6</span><span class="w"> </span><span class="m">2016</span>,<span class="w"> </span><span class="m">10</span>:59:36<span class="o">)</span>
<span class="w"> </span>...
&gt;&gt;&gt;<span class="w"> </span>import<span class="w"> </span>sys
&gt;&gt;&gt;<span class="w"> </span>sys.path
<span class="o">[</span><span class="s1">&#39;&#39;</span>,<span class="w"> </span><span class="s1">&#39;/usr/local/lib/python35.zip&#39;</span>,<span class="w"> </span>...,
<span class="s1">&#39;~/envs/tutorial-env/lib/python3.5/site-packages&#39;</span><span class="o">]</span>
&gt;&gt;&gt;
</pre></div>
</div>
<p>To deactivate a virtual environment, type:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">deactivate</span>
</pre></div>
</div>
<p>into the terminal.</p>
</section>
<section id="managing-packages-with-pip">
<h2><span class="section-number">12.3. </span>Managing Packages with pip<a class="headerlink" href="#managing-packages-with-pip" title="Link to this heading"></a></h2>
<p>You can install, upgrade, and remove packages using a program called
<strong class="program">pip</strong>. By default <code class="docutils literal notranslate"><span class="pre">pip</span></code> will install packages from the <a class="reference external" href="https://pypi.org">Python
Package Index</a>. You can browse the Python
Package Index by going to it in your web browser.</p>
<p><code class="docutils literal notranslate"><span class="pre">pip</span></code> has a number of subcommands: “install”, “uninstall”,
“freeze”, etc. (Consult the <a class="reference internal" href="../installing/index.html#installing-index"><span class="std std-ref">Installing Python Modules</span></a> guide for
complete documentation for <code class="docutils literal notranslate"><span class="pre">pip</span></code>.)</p>
<p>You can install the latest version of a package by specifying a packages name:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="o">(</span>tutorial-env<span class="o">)</span><span class="w"> </span>$<span class="w"> </span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>novas
Collecting<span class="w"> </span>novas
<span class="w"> </span>Downloading<span class="w"> </span>novas-3.1.1.3.tar.gz<span class="w"> </span><span class="o">(</span>136kB<span class="o">)</span>
Installing<span class="w"> </span>collected<span class="w"> </span>packages:<span class="w"> </span>novas
<span class="w"> </span>Running<span class="w"> </span>setup.py<span class="w"> </span>install<span class="w"> </span><span class="k">for</span><span class="w"> </span>novas
Successfully<span class="w"> </span>installed<span class="w"> </span>novas-3.1.1.3
</pre></div>
</div>
<p>You can also install a specific version of a package by giving the
package name followed by <code class="docutils literal notranslate"><span class="pre">==</span></code> and the version number:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="o">(</span>tutorial-env<span class="o">)</span><span class="w"> </span>$<span class="w"> </span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span><span class="nv">requests</span><span class="o">==</span><span class="m">2</span>.6.0
Collecting<span class="w"> </span><span class="nv">requests</span><span class="o">==</span><span class="m">2</span>.6.0
<span class="w"> </span>Using<span class="w"> </span>cached<span class="w"> </span>requests-2.6.0-py2.py3-none-any.whl
Installing<span class="w"> </span>collected<span class="w"> </span>packages:<span class="w"> </span>requests
Successfully<span class="w"> </span>installed<span class="w"> </span>requests-2.6.0
</pre></div>
</div>
<p>If you re-run this command, <code class="docutils literal notranslate"><span class="pre">pip</span></code> will notice that the requested
version is already installed and do nothing. You can supply a
different version number to get that version, or you can run <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">--upgrade</span></code> to upgrade the package to the latest version:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="o">(</span>tutorial-env<span class="o">)</span><span class="w"> </span>$<span class="w"> </span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>--upgrade<span class="w"> </span>requests
Collecting<span class="w"> </span>requests
Installing<span class="w"> </span>collected<span class="w"> </span>packages:<span class="w"> </span>requests
<span class="w"> </span>Found<span class="w"> </span>existing<span class="w"> </span>installation:<span class="w"> </span>requests<span class="w"> </span><span class="m">2</span>.6.0
<span class="w"> </span>Uninstalling<span class="w"> </span>requests-2.6.0:
<span class="w"> </span>Successfully<span class="w"> </span>uninstalled<span class="w"> </span>requests-2.6.0
Successfully<span class="w"> </span>installed<span class="w"> </span>requests-2.7.0
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">pip</span> <span class="pre">uninstall</span></code> followed by one or more package names will
remove the packages from the virtual environment.</p>
<p><code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">pip</span> <span class="pre">show</span></code> will display information about a particular package:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="o">(</span>tutorial-env<span class="o">)</span><span class="w"> </span>$<span class="w"> </span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>show<span class="w"> </span>requests
---
Metadata-Version:<span class="w"> </span><span class="m">2</span>.0
Name:<span class="w"> </span>requests
Version:<span class="w"> </span><span class="m">2</span>.7.0
Summary:<span class="w"> </span>Python<span class="w"> </span>HTTP<span class="w"> </span><span class="k">for</span><span class="w"> </span>Humans.
Home-page:<span class="w"> </span>http://python-requests.org
Author:<span class="w"> </span>Kenneth<span class="w"> </span>Reitz
Author-email:<span class="w"> </span>me@kennethreitz.com
License:<span class="w"> </span>Apache<span class="w"> </span><span class="m">2</span>.0
Location:<span class="w"> </span>/Users/akuchling/envs/tutorial-env/lib/python3.4/site-packages
Requires:
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">pip</span> <span class="pre">list</span></code> will display all of the packages installed in
the virtual environment:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="o">(</span>tutorial-env<span class="o">)</span><span class="w"> </span>$<span class="w"> </span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>list
novas<span class="w"> </span><span class="o">(</span><span class="m">3</span>.1.1.3<span class="o">)</span>
numpy<span class="w"> </span><span class="o">(</span><span class="m">1</span>.9.2<span class="o">)</span>
pip<span class="w"> </span><span class="o">(</span><span class="m">7</span>.0.3<span class="o">)</span>
requests<span class="w"> </span><span class="o">(</span><span class="m">2</span>.7.0<span class="o">)</span>
setuptools<span class="w"> </span><span class="o">(</span><span class="m">16</span>.0<span class="o">)</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">pip</span> <span class="pre">freeze</span></code> will produce a similar list of the installed packages,
but the output uses the format that <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></code> expects.
A common convention is to put this list in a <code class="docutils literal notranslate"><span class="pre">requirements.txt</span></code> file:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="o">(</span>tutorial-env<span class="o">)</span><span class="w"> </span>$<span class="w"> </span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>freeze<span class="w"> </span>&gt;<span class="w"> </span>requirements.txt
<span class="o">(</span>tutorial-env<span class="o">)</span><span class="w"> </span>$<span class="w"> </span>cat<span class="w"> </span>requirements.txt
<span class="nv">novas</span><span class="o">==</span><span class="m">3</span>.1.1.3
<span class="nv">numpy</span><span class="o">==</span><span class="m">1</span>.9.2
<span class="nv">requests</span><span class="o">==</span><span class="m">2</span>.7.0
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">requirements.txt</span></code> can then be committed to version control and
shipped as part of an application. Users can then install all the
necessary packages with <code class="docutils literal notranslate"><span class="pre">install</span> <span class="pre">-r</span></code>:</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span><span class="o">(</span>tutorial-env<span class="o">)</span><span class="w"> </span>$<span class="w"> </span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>-r<span class="w"> </span>requirements.txt
Collecting<span class="w"> </span><span class="nv">novas</span><span class="o">==</span><span class="m">3</span>.1.1.3<span class="w"> </span><span class="o">(</span>from<span class="w"> </span>-r<span class="w"> </span>requirements.txt<span class="w"> </span><span class="o">(</span>line<span class="w"> </span><span class="m">1</span><span class="o">))</span>
<span class="w"> </span>...
Collecting<span class="w"> </span><span class="nv">numpy</span><span class="o">==</span><span class="m">1</span>.9.2<span class="w"> </span><span class="o">(</span>from<span class="w"> </span>-r<span class="w"> </span>requirements.txt<span class="w"> </span><span class="o">(</span>line<span class="w"> </span><span class="m">2</span><span class="o">))</span>
<span class="w"> </span>...
Collecting<span class="w"> </span><span class="nv">requests</span><span class="o">==</span><span class="m">2</span>.7.0<span class="w"> </span><span class="o">(</span>from<span class="w"> </span>-r<span class="w"> </span>requirements.txt<span class="w"> </span><span class="o">(</span>line<span class="w"> </span><span class="m">3</span><span class="o">))</span>
<span class="w"> </span>...
Installing<span class="w"> </span>collected<span class="w"> </span>packages:<span class="w"> </span>novas,<span class="w"> </span>numpy,<span class="w"> </span>requests
<span class="w"> </span>Running<span class="w"> </span>setup.py<span class="w"> </span>install<span class="w"> </span><span class="k">for</span><span class="w"> </span>novas
Successfully<span class="w"> </span>installed<span class="w"> </span>novas-3.1.1.3<span class="w"> </span>numpy-1.9.2<span class="w"> </span>requests-2.7.0
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">pip</span></code> has many more options. Consult the <a class="reference internal" href="../installing/index.html#installing-index"><span class="std std-ref">Installing Python Modules</span></a>
guide for complete documentation for <code class="docutils literal notranslate"><span class="pre">pip</span></code>. When youve written
a package and want to make it available on the Python Package Index,
consult the <a class="reference external" href="https://packaging.python.org/en/latest/tutorials/packaging-projects/">Python packaging user guide</a>.</p>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<div>
<h3><a href="../contents.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">12. Virtual Environments and Packages</a><ul>
<li><a class="reference internal" href="#introduction">12.1. Introduction</a></li>
<li><a class="reference internal" href="#creating-virtual-environments">12.2. Creating Virtual Environments</a></li>
<li><a class="reference internal" href="#managing-packages-with-pip">12.3. Managing Packages with pip</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="stdlib2.html"
title="previous chapter"><span class="section-number">11. </span>Brief Tour of the Standard Library — Part II</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="whatnow.html"
title="next chapter"><span class="section-number">13. </span>What Now?</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/tutorial/venv.rst"
rel="nofollow">Show Source
</a>
</li>
</ul>
</div>
</div>
<div id="sidebarbutton" title="Collapse sidebar">
<span>«</span>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<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="whatnow.html" title="13. What Now?"
>next</a> |</li>
<li class="right" >
<a href="stdlib2.html" title="11. Brief Tour of the Standard Library — Part II"
>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.13.3 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="index.html" >The Python Tutorial</a> &#187;</li>
<li class="nav-item nav-item-this"><a href=""><span class="section-number">12. </span>Virtual Environments and Packages</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" id="search-box" />
<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-2025, 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 Apr 08, 2025 (14:33 UTC).
<a href="/bugs.html">Found a bug</a>?
<br />
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
</div>
</body>
</html>