<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>pip — pip v0.8.2 documentation</title> <link rel="stylesheet" href="_static/nature.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '', VERSION: '0.8.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="top" title="pip v0.8.2 documentation" href="#" /> <link rel="next" title="News for pip" href="news.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="news.html" title="News for pip" accesskey="N">next</a></li> <li><a href="#">pip v0.8.2 documentation</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="pip"> <h1>pip<a class="headerlink" href="#pip" title="Permalink to this headline">¶</a></h1> <p>pip installs Python packages.</p> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="news.html">News for pip</a></li> <li class="toctree-l1"><a class="reference internal" href="requirement-format.html">The requirements file format</a></li> <li class="toctree-l1"><a class="reference internal" href="configuration.html">Configuration</a></li> <li class="toctree-l1"><a class="reference internal" href="how-to-contribute.html">How To Contribute to Pip</a></li> <li class="toctree-l1"><a class="reference internal" href="running-tests.html">Running the Tests</a></li> </ul> </div> <div class="section" id="introduction"> <h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2> <p>pip installs packages. Python packages.</p> <p>If you use <a class="reference external" href="http://virtualenv.openplans.org">virtualenv</a> – a tool for installing libraries in a local and isolated manner – you’ll automatically get a copy of pip. Free bonus!</p> <p>Once you have pip, you can use it like this:</p> <div class="highlight-python"><pre>$ pip install SomePackage</pre> </div> <p>SomePackage is some package you’ll find on <a class="reference external" href="http://pypi.python.org/pypi/">PyPI</a>. This installs the package and all its dependencies.</p> <p>pip does other stuff too, with packages, but install is the biggest one. You can <tt class="docutils literal"><span class="pre">pip</span> <span class="pre">uninstall</span></tt> too.</p> <p>You can also install from a URL (that points to a tar or zip file), install from some version control system (use URLs like <tt class="docutils literal"><span class="pre">hg+http://domain/repo</span></tt> – or prefix <tt class="docutils literal"><span class="pre">git+</span></tt>, <tt class="docutils literal"><span class="pre">svn+</span></tt> etc). pip knows a bunch of stuff about revisions and stuff, so if you need to do things like install a very specific revision from a repository pip can do that too.</p> <p>If you’ve ever used <tt class="docutils literal"><span class="pre">python</span> <span class="pre">setup.py</span> <span class="pre">develop</span></tt>, you can do something like that with <tt class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">-e</span> <span class="pre">./</span></tt> – this works with packages that use <tt class="docutils literal"><span class="pre">distutils</span></tt> too (usually this only works with Setuptools projects).</p> <p>You can use <tt class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">--upgrade</span> <span class="pre">SomePackage</span></tt> to upgrade to a newer version, or <tt class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">SomePackage==1.0.4</span></tt> to install a very specific version.</p> </div> <div class="section" id="pip-compared-to-easy-install"> <h2>Pip Compared To easy_install<a class="headerlink" href="#pip-compared-to-easy-install" title="Permalink to this headline">¶</a></h2> <p>pip is a replacement for <a class="reference external" href="http://peak.telecommunity.com/DevCenter/EasyInstall">easy_install</a>. It uses mostly the same techniques for finding packages, so packages that were made easy_installable should be pip-installable as well.</p> <p>pip is meant to improve on easy_install. Some of the improvements:</p> <ul class="simple"> <li>All packages are downloaded before installation. Partially-completed installation doesn’t occur as a result.</li> <li>Care is taken to present useful output on the console.</li> <li>The reasons for actions are kept track of. For instance, if a package is being installed, pip keeps track of why that package was required.</li> <li>Error messages should be useful.</li> <li>The code is relatively concise and cohesive, making it easier to use programmatically.</li> <li>Packages don’t have to be installed as egg archives, they can be installed flat (while keeping the egg metadata).</li> <li>Native support for other version control systems (Git, Mercurial and Bazaar)</li> <li>Uninstallation of packages.</li> <li>Simple to define fixed sets of requirements and reliably reproduce a set of packages.</li> </ul> <p>pip doesn’t do everything that easy_install does. Specifically:</p> <ul class="simple"> <li>It cannot install from eggs. It only installs from source. (In the future it would be good if it could install binaries from Windows <tt class="docutils literal"><span class="pre">.exe</span></tt> or <tt class="docutils literal"><span class="pre">.msi</span></tt> – binary install on other platforms is not a priority.)</li> <li>It doesn’t understand Setuptools extras (like <tt class="docutils literal"><span class="pre">package[test]</span></tt>). This should be added eventually.</li> <li>It is incompatible with some packages that extensively customize distutils or setuptools in their <tt class="docutils literal"><span class="pre">setup.py</span></tt> files.</li> </ul> <p>pip is complementary with <a class="reference external" href="http://pypi.python.org/pypi/virtualenv">virtualenv</a>, and it is encouraged that you use virtualenv to isolate your installation.</p> </div> <div class="section" id="community"> <h2>Community<a class="headerlink" href="#community" title="Permalink to this headline">¶</a></h2> <p>The homepage for pip is temporarily located <a class="reference external" href="http://pypi.python.org/pypi/pip">on PyPI</a> – a more proper homepage will follow. Bugs can go on the <a class="reference external" href="https://github.com/pypa/pip/issues/">pip issue tracker</a>. Discussion should happen on the <a class="reference external" href="http://groups.google.com/group/python-virtualenv?hl=en">virtualenv email group</a>.</p> </div> <div class="section" id="uninstall"> <h2>Uninstall<a class="headerlink" href="#uninstall" title="Permalink to this headline">¶</a></h2> <p>pip is able to uninstall most installed packages with <tt class="docutils literal"><span class="pre">pip</span> <span class="pre">uninstall</span> <span class="pre">package-name</span></tt>.</p> <p>Known exceptions include pure-distutils packages installed with <tt class="docutils literal"><span class="pre">python</span> <span class="pre">setup.py</span> <span class="pre">install</span></tt> (such packages leave behind no metadata allowing determination of what files were installed), and script wrappers installed by develop-installs (<tt class="docutils literal"><span class="pre">python</span> <span class="pre">setup.py</span> <span class="pre">develop</span></tt>).</p> <p>pip also performs an automatic uninstall of an old version of a package before upgrading to a newer version, so outdated files (and egg-info data) from conflicting versions aren’t left hanging around to cause trouble. The old version of the package is automatically restored if the new version fails to download or install.</p> </div> <div class="section" id="requirements-files"> <span id="requirements-file"></span><h2>Requirements Files<a class="headerlink" href="#requirements-files" title="Permalink to this headline">¶</a></h2> <p>When installing software, and Python packages in particular, it’s common that you get a lot of libraries installed. You just did <tt class="docutils literal"><span class="pre">easy_install</span> <span class="pre">MyPackage</span></tt> and you get a dozen packages. Each of these packages has its own version.</p> <p>Maybe you ran that installation and it works. Great! Will it keep working? Did you have to provide special options to get it to find everything? Did you have to install a bunch of other optional pieces? Most of all, will you be able to do it again? Requirements files give you a way to create an <em>environment</em>: a <em>set</em> of packages that work together.</p> <p>If you’ve ever tried to setup an application on a new system, or with slightly updated pieces, and had it fail, pip requirements are for you. If you haven’t had this problem then you will eventually, so pip requirements are for you too – requirements make explicit, repeatable installation of packages.</p> <p>So what are requirements files? They are very simple: lists of packages to install. Instead of running something like <tt class="docutils literal"><span class="pre">pip</span> <span class="pre">MyApp</span></tt> and getting whatever libraries come along, you can create a requirements file something like:</p> <div class="highlight-python"><pre>MyApp Framework==0.9.4 Library>=0.2</pre> </div> <p>Then, regardless of what MyApp lists in <tt class="docutils literal"><span class="pre">setup.py</span></tt>, you’ll get a specific version of Framework (0.9.4) and at least the 0.2 version of Library. (You might think you could list these specific versions in MyApp’s <tt class="docutils literal"><span class="pre">setup.py</span></tt> – but if you do that you’ll have to edit MyApp if you want to try a new version of Framework, or release a new version of MyApp if you determine that Library 0.3 doesn’t work with your application.) You can also add optional libraries and support tools that MyApp doesn’t strictly require, giving people a set of recommended libraries.</p> <p>You can also include “editable” packages – packages that are checked out from Subversion, Git, Mercurial and Bazaar. These are just like using the <tt class="docutils literal"><span class="pre">-e</span></tt> option to pip. They look like:</p> <div class="highlight-python"><pre>-e svn+http://myrepo/svn/MyApp#egg=MyApp</pre> </div> <p>You have to start the URL with <tt class="docutils literal"><span class="pre">svn+</span></tt> (<tt class="docutils literal"><span class="pre">git+</span></tt>, <tt class="docutils literal"><span class="pre">hg+</span></tt> or <tt class="docutils literal"><span class="pre">bzr+</span></tt>), and you have to include <tt class="docutils literal"><span class="pre">#egg=Package</span></tt> so pip knows what to expect at that URL. You can also include <tt class="docutils literal"><span class="pre">@rev</span></tt> in the URL, e.g., <tt class="docutils literal"><span class="pre">@275</span></tt> to check out revision 275.</p> <p>Requirement files are mostly <em>flat</em>. Maybe <tt class="docutils literal"><span class="pre">MyApp</span></tt> requires <tt class="docutils literal"><span class="pre">Framework</span></tt>, and <tt class="docutils literal"><span class="pre">Framework</span></tt> requires <tt class="docutils literal"><span class="pre">Library</span></tt>. I encourage you to still list all these in a single requirement file; it is the nature of Python programs that there are implicit bindings <em>directly</em> between MyApp and Library. For instance, Framework might expose one of Library’s objects, and so if Library is updated it might directly break MyApp. If that happens you can update the requirements file to force an earlier version of Library, and you can do that without having to re-release MyApp at all.</p> <p>Read the <a class="reference external" href="http://pip.openplans.org/requirement-format.html">requirements file format</a> to learn about other features.</p> </div> <div class="section" id="freezing-requirements"> <h2>Freezing Requirements<a class="headerlink" href="#freezing-requirements" title="Permalink to this headline">¶</a></h2> <p>So you have a working set of packages, and you want to be able to install them elsewhere. <a class="reference internal" href="#requirements-files">Requirements files</a> let you install exact versions, but it won’t tell you what all the exact versions are.</p> <p>To create a new requirements file from a known working environment, use:</p> <div class="highlight-python"><pre>$ pip freeze > stable-req.txt</pre> </div> <p>This will write a listing of <em>all</em> installed libraries to <tt class="docutils literal"><span class="pre">stable-req.txt</span></tt> with exact versions for every library. You may want to edit the file down after generating (e.g., to eliminate unnecessary libraries), but it’ll give you a stable starting point for constructing your requirements file.</p> <p>You can also give it an existing requirements file, and it will use that as a sort of template for the new file. So if you do:</p> <div class="highlight-python"><pre>$ pip freeze -r devel-req.txt > stable-req.txt</pre> </div> <p>it will keep the packages listed in <tt class="docutils literal"><span class="pre">devel-req.txt</span></tt> in order and preserve comments.</p> </div> <div class="section" id="bundles"> <h2>Bundles<a class="headerlink" href="#bundles" title="Permalink to this headline">¶</a></h2> <p>Another way to distribute a set of libraries is a bundle format (specific to pip). This format is not stable at this time (there simply hasn’t been any feedback, nor a great deal of thought). A bundle file contains all the source for your package, and you can have pip install them all together. Once you have the bundle file further network access won’t be necessary. To build a bundle file, do:</p> <div class="highlight-python"><pre>$ pip bundle MyApp.pybundle MyApp</pre> </div> <p>(Using a <a class="reference internal" href="#requirements-file">requirements file</a> would be wise.) Then someone else can get the file <tt class="docutils literal"><span class="pre">MyApp.pybundle</span></tt> and run:</p> <div class="highlight-python"><pre>$ pip install MyApp.pybundle</pre> </div> <p>This is <em>not</em> a binary format. This only packages source. If you have binary packages, then the person who installs the files will have to have a compiler, any necessary headers installed, etc. Binary packages are hard, this is relatively easy.</p> </div> <div class="section" id="using-pip-with-virtualenv"> <h2>Using pip with virtualenv<a class="headerlink" href="#using-pip-with-virtualenv" title="Permalink to this headline">¶</a></h2> <p>pip is most nutritious when used with <a class="reference external" href="http://pypi.python.org/pypi/virtualenv">virtualenv</a>. One of the reasons pip doesn’t install “multi-version” eggs is that virtualenv removes much of the need for it. Because pip is installed by virtualenv, just use <tt class="docutils literal"><span class="pre">path/to/my/environment/bin/pip</span></tt> to install things into that specific environment.</p> <p>To tell pip to only run if there is a virtualenv currently activated, and to bail if not, use:</p> <div class="highlight-python"><pre>export PIP_REQUIRE_VIRTUALENV=true</pre> </div> <p>To tell pip to automatically use the currently active virtualenv:</p> <div class="highlight-python"><pre>export PIP_RESPECT_VIRTUALENV=true</pre> </div> <p>Providing an environment with <tt class="docutils literal"><span class="pre">-E</span></tt> will be ignored.</p> </div> <div class="section" id="using-pip-with-virtualenvwrapper"> <h2>Using pip with virtualenvwrapper<a class="headerlink" href="#using-pip-with-virtualenvwrapper" title="Permalink to this headline">¶</a></h2> <p>If you are using <a class="reference external" href="http://www.doughellmann.com/projects/virtualenvwrapper/">virtualenvwrapper</a>, you might want pip to automatically create its virtualenvs in your <tt class="docutils literal"><span class="pre">$WORKON_HOME</span></tt>.</p> <p>You can tell pip to do so by defining <tt class="docutils literal"><span class="pre">PIP_VIRTUALENV_BASE</span></tt> in your environment and setting it to the same value as that of <tt class="docutils literal"><span class="pre">$WORKON_HOME</span></tt>.</p> <p>Do so by adding the line:</p> <div class="highlight-python"><pre>export PIP_VIRTUALENV_BASE=$WORKON_HOME</pre> </div> <p>in your .bashrc under the line starting with <tt class="docutils literal"><span class="pre">export</span> <span class="pre">WORKON_HOME</span></tt>.</p> </div> <div class="section" id="using-pip-with-buildout"> <h2>Using pip with buildout<a class="headerlink" href="#using-pip-with-buildout" title="Permalink to this headline">¶</a></h2> <p>If you are using <a class="reference external" href="http://pypi.python.org/pypi/zc.buildout">zc.buildout</a> you should look at <a class="reference external" href="http://pypi.python.org/pypi/gp.recipe.pip">gp.recipe.pip</a> as an option to use pip and virtualenv in your buildouts.</p> </div> <div class="section" id="command-line-completion"> <h2>Command line completion<a class="headerlink" href="#command-line-completion" title="Permalink to this headline">¶</a></h2> <p>pip comes with support for command line completion in bash and zsh and allows you tab complete commands and options. To enable it you simply need copy the required shell script to the your shell startup file (e.g. <tt class="docutils literal"><span class="pre">.profile</span></tt> or <tt class="docutils literal"><span class="pre">.zprofile</span></tt>) by running the special <tt class="docutils literal"><span class="pre">completion</span></tt> command, e.g. for bash:</p> <div class="highlight-python"><pre>$ pip completion --bash >> ~/.profile</pre> </div> <p>And for zsh:</p> <div class="highlight-python"><pre>$ pip completion --zsh >> ~/.zprofile</pre> </div> <p>Alternatively, you can use the result of the <tt class="docutils literal"><span class="pre">completion</span></tt> command directly with the eval function of you shell, e.g. by adding:</p> <div class="highlight-python"><pre>eval "`pip completion --bash`"</pre> </div> <p>to your startup file.</p> </div> <div class="section" id="searching-for-packages"> <h2>Searching for packages<a class="headerlink" href="#searching-for-packages" title="Permalink to this headline">¶</a></h2> <p>pip can search the <a class="reference external" href="http://pypi.python.org/pypi">Python Package Index</a> (PyPI) for packages using the <tt class="docutils literal"><span class="pre">pip</span> <span class="pre">search</span></tt> command. To search, run:</p> <div class="highlight-python"><pre>$ pip search "query"</pre> </div> <p>The query will be used to search the names and summaries of all packages indexed.</p> <p>pip searches <a class="reference external" href="http://pypi.python.org/pypi">http://pypi.python.org/pypi</a> by default but alternative indexes can be searched by using the <tt class="docutils literal"><span class="pre">--index</span></tt> flag.</p> </div> <div class="section" id="mirror-support"> <h2>Mirror support<a class="headerlink" href="#mirror-support" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference external" href="http://pypi.python.org/mirrors">PyPI mirroring infrastructure</a> as described in <a class="reference external" href="http://www.python.org/dev/peps/pep-0381/">PEP 381</a> can be used by passing the <tt class="docutils literal"><span class="pre">--use-mirrors</span></tt> option to the install command. Alternatively, you can use the other ways to configure pip, e.g.:</p> <div class="highlight-python"><pre>$ export PIP_USE_MIRRORS=true</pre> </div> <p>If enabled, pip will automatically query the DNS entry of the mirror index URL to find the list of mirrors to use. In case you want to override this list, please use the <tt class="docutils literal"><span class="pre">--mirrors</span></tt> option of the install command, or add to your pip configuration file:</p> <div class="highlight-python"><pre>[install] use-mirrors = true mirrors = http://d.pypi.python.org http://b.pypi.python.org</pre> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="#">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">pip</a><ul> <li><a class="reference internal" href="#introduction">Introduction</a></li> <li><a class="reference internal" href="#pip-compared-to-easy-install">Pip Compared To easy_install</a></li> <li><a class="reference internal" href="#community">Community</a></li> <li><a class="reference internal" href="#uninstall">Uninstall</a></li> <li><a class="reference internal" href="#requirements-files">Requirements Files</a></li> <li><a class="reference internal" href="#freezing-requirements">Freezing Requirements</a></li> <li><a class="reference internal" href="#bundles">Bundles</a></li> <li><a class="reference internal" href="#using-pip-with-virtualenv">Using pip with virtualenv</a></li> <li><a class="reference internal" href="#using-pip-with-virtualenvwrapper">Using pip with virtualenvwrapper</a></li> <li><a class="reference internal" href="#using-pip-with-buildout">Using pip with buildout</a></li> <li><a class="reference internal" href="#command-line-completion">Command line completion</a></li> <li><a class="reference internal" href="#searching-for-packages">Searching for packages</a></li> <li><a class="reference internal" href="#mirror-support">Mirror support</a></li> </ul> </li> </ul> <h4>Next topic</h4> <p class="topless"><a href="news.html" title="next chapter">News for pip</a></p> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" size="18" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="news.html" title="News for pip" >next</a></li> <li><a href="#">pip v0.8.2 documentation</a> »</li> </ul> </div> <div class="footer"> © Copyright 2008-2011, The pip developers. Last updated on Mar 06, 2011. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7. </div> </body> </html>