2008-10-16 00:24:00 +02:00
|
|
|
pip
|
|
|
|
===
|
2008-10-16 00:02:57 +02:00
|
|
|
|
2011-05-01 01:04:56 +02:00
|
|
|
pip is a tool for installing and managing Python packages, such as those
|
|
|
|
found in the `Python Package Index <http://pypi.python.org/pypi>`_.
|
|
|
|
|
|
|
|
pip is a replacement for `easy_install
|
|
|
|
<http://peak.telecommunity.com/DevCenter/EasyInstall>`_. It mostly
|
|
|
|
uses the same techniques for finding packages, so packages that are
|
|
|
|
easy_installable should be pip-installable as well. This means that
|
|
|
|
you can use ``pip install SomePackage`` instead of ``easy_install
|
|
|
|
SomePackage``.
|
|
|
|
|
|
|
|
In order to use pip, you must first install `setuptools
|
|
|
|
<http://pypi.python.org/pypi/setuptools>`_ or `distribute
|
2011-05-01 19:53:35 +02:00
|
|
|
<http://pypi.python.org/pypi/distribute>`_. If you use `virtualenv
|
|
|
|
<http://www.virtualenv.org>`_, a copy of pip will be automatically be
|
|
|
|
installed in each virtual environment you create.
|
2009-04-03 23:20:20 +02:00
|
|
|
|
2011-05-01 19:51:33 +02:00
|
|
|
.. comment: split here
|
|
|
|
|
2008-10-16 00:02:57 +02:00
|
|
|
.. toctree::
|
2009-10-25 02:25:13 +01:00
|
|
|
:maxdepth: 1
|
2008-10-16 00:02:57 +02:00
|
|
|
|
|
|
|
news
|
2011-03-15 06:43:03 +01:00
|
|
|
installing
|
2011-09-24 22:47:57 +02:00
|
|
|
usage
|
2011-09-24 22:56:37 +02:00
|
|
|
requirements
|
2009-10-25 02:22:53 +01:00
|
|
|
configuration
|
2010-06-08 03:17:34 +02:00
|
|
|
how-to-contribute
|
2011-03-06 18:19:41 +01:00
|
|
|
running-tests
|
2008-10-16 00:02:57 +02:00
|
|
|
|
|
|
|
.. comment: split here
|
|
|
|
|
2010-05-28 06:28:39 +02:00
|
|
|
Pip Compared To easy_install
|
|
|
|
----------------------------
|
|
|
|
|
2008-10-16 00:24:00 +02:00
|
|
|
pip is meant to improve on easy_install. Some of the improvements:
|
2008-10-16 00:02:57 +02:00
|
|
|
|
|
|
|
* All packages are downloaded before installation. Partially-completed
|
|
|
|
installation doesn't occur as a result.
|
|
|
|
|
|
|
|
* Care is taken to present useful output on the console.
|
|
|
|
|
|
|
|
* The reasons for actions are kept track of. For instance, if a package is
|
2008-10-16 00:24:00 +02:00
|
|
|
being installed, pip keeps track of why that package was required.
|
2008-10-16 00:02:57 +02:00
|
|
|
|
|
|
|
* Error messages should be useful.
|
|
|
|
|
|
|
|
* The code is relatively concise and cohesive, making it easier to use
|
|
|
|
programmatically.
|
|
|
|
|
|
|
|
* Packages don't have to be installed as egg archives, they can be installed
|
|
|
|
flat (while keeping the egg metadata).
|
|
|
|
|
2009-01-21 15:39:50 +01:00
|
|
|
* Native support for other version control systems (Git, Mercurial and Bazaar)
|
|
|
|
|
2009-10-02 20:06:26 +02:00
|
|
|
* Uninstallation of packages.
|
2008-10-16 00:02:57 +02:00
|
|
|
|
2009-10-02 20:06:26 +02:00
|
|
|
* Simple to define fixed sets of requirements and reliably reproduce a
|
|
|
|
set of packages.
|
2008-10-16 00:02:57 +02:00
|
|
|
|
2010-07-15 19:41:13 +02:00
|
|
|
pip doesn't do everything that easy_install does. Specifically:
|
|
|
|
|
|
|
|
* It cannot install from eggs. It only installs from source. (In the
|
|
|
|
future it would be good if it could install binaries from Windows ``.exe``
|
|
|
|
or ``.msi`` -- binary install on other platforms is not a priority.)
|
|
|
|
|
|
|
|
* It doesn't understand Setuptools extras (like ``package[test]``). This should
|
|
|
|
be added eventually.
|
|
|
|
|
|
|
|
* It is incompatible with some packages that extensively customize distutils
|
|
|
|
or setuptools in their ``setup.py`` files.
|
|
|
|
|
2008-10-16 00:24:00 +02:00
|
|
|
pip is complementary with `virtualenv
|
2010-05-28 06:30:41 +02:00
|
|
|
<http://pypi.python.org/pypi/virtualenv>`__, and it is encouraged that you use
|
2008-10-16 00:02:57 +02:00
|
|
|
virtualenv to isolate your installation.
|
|
|
|
|
|
|
|
Community
|
|
|
|
---------
|
|
|
|
|
2011-05-01 01:04:56 +02:00
|
|
|
The homepage for pip is at `pip-installer.org <http://www.pip-installer.org/>`_.
|
|
|
|
Bugs can be filed in the `pip issue tracker
|
|
|
|
<https://github.com/pypa/pip/issues/>`_. Discussion happens on the
|
2009-01-21 19:12:04 +01:00
|
|
|
`virtualenv email group
|
2008-10-16 00:02:57 +02:00
|
|
|
<http://groups.google.com/group/python-virtualenv?hl=en>`_.
|
|
|
|
|
|
|
|
Bundles
|
|
|
|
-------
|
|
|
|
|
|
|
|
Another way to distribute a set of libraries is a bundle format (specific to
|
2008-10-16 00:24:00 +02:00
|
|
|
pip). This format is not stable at this time (there simply hasn't been
|
2008-10-16 00:02:57 +02:00
|
|
|
any feedback, nor a great deal of thought). A bundle file contains all the
|
2010-04-22 10:07:57 +02:00
|
|
|
source for your package, and you can have pip install them all together.
|
2008-10-16 00:02:57 +02:00
|
|
|
Once you have the bundle file further network access won't be necessary. To
|
|
|
|
build a bundle file, do::
|
|
|
|
|
2009-02-04 19:44:51 +01:00
|
|
|
$ pip bundle MyApp.pybundle MyApp
|
2008-10-16 00:02:57 +02:00
|
|
|
|
|
|
|
(Using a `requirements file`_ would be wise.) Then someone else can get the
|
|
|
|
file ``MyApp.pybundle`` and run::
|
|
|
|
|
2008-10-16 00:24:00 +02:00
|
|
|
$ pip install MyApp.pybundle
|
2008-10-16 00:02:57 +02:00
|
|
|
|
|
|
|
This is *not* 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.
|
|
|
|
|
2009-10-25 02:25:13 +01:00
|
|
|
Using pip with virtualenv
|
2008-10-16 00:24:00 +02:00
|
|
|
-------------------------
|
2008-10-16 00:02:57 +02:00
|
|
|
|
2008-10-16 00:24:00 +02:00
|
|
|
pip is most nutritious when used with `virtualenv
|
2010-05-28 06:30:41 +02:00
|
|
|
<http://pypi.python.org/pypi/virtualenv>`__. One of the reasons pip
|
2008-10-16 00:02:57 +02:00
|
|
|
doesn't install "multi-version" eggs is that virtualenv removes much of the need
|
2010-05-28 06:28:39 +02:00
|
|
|
for it. Because pip is installed by virtualenv, just use
|
|
|
|
``path/to/my/environment/bin/pip`` to install things into that
|
|
|
|
specific environment.
|
2008-12-09 19:04:33 +01:00
|
|
|
|
2009-10-25 02:24:45 +01:00
|
|
|
To tell pip to only run if there is a virtualenv currently activated,
|
|
|
|
and to bail if not, use::
|
|
|
|
|
|
|
|
export PIP_REQUIRE_VIRTUALENV=true
|
|
|
|
|
2009-05-11 18:16:22 +02:00
|
|
|
|
|
|
|
Using pip with virtualenvwrapper
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
If you are using `virtualenvwrapper
|
|
|
|
<http://www.doughellmann.com/projects/virtualenvwrapper/>`_, you might
|
|
|
|
want pip to automatically create its virtualenvs in your
|
|
|
|
``$WORKON_HOME``.
|
|
|
|
|
|
|
|
You can tell pip to do so by defining ``PIP_VIRTUALENV_BASE`` in your
|
|
|
|
environment and setting it to the same value as that of
|
|
|
|
``$WORKON_HOME``.
|
|
|
|
|
2009-07-28 10:11:39 +02:00
|
|
|
Do so by adding the line::
|
2009-05-11 18:16:22 +02:00
|
|
|
|
|
|
|
export PIP_VIRTUALENV_BASE=$WORKON_HOME
|
|
|
|
|
2009-07-28 10:11:39 +02:00
|
|
|
in your .bashrc under the line starting with ``export WORKON_HOME``.
|
2009-10-25 02:24:45 +01:00
|
|
|
|
|
|
|
Using pip with buildout
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
If you are using `zc.buildout
|
|
|
|
<http://pypi.python.org/pypi/zc.buildout>`_ you should look at
|
|
|
|
`gp.recipe.pip <http://pypi.python.org/pypi/gp.recipe.pip>`_ as an
|
|
|
|
option to use pip and virtualenv in your buildouts.
|
2009-11-07 04:46:30 +01:00
|
|
|
|
|
|
|
Command line completion
|
|
|
|
-----------------------
|
|
|
|
|
2009-11-07 19:18:03 +01:00
|
|
|
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. ``.profile`` or ``.zprofile``) by running the special ``completion``
|
|
|
|
command, e.g. for bash::
|
2009-11-07 04:46:30 +01:00
|
|
|
|
2009-11-09 17:27:35 +01:00
|
|
|
$ pip completion --bash >> ~/.profile
|
2009-11-07 04:46:30 +01:00
|
|
|
|
2009-11-07 15:13:28 +01:00
|
|
|
And for zsh::
|
|
|
|
|
2009-11-09 17:27:35 +01:00
|
|
|
$ pip completion --zsh >> ~/.zprofile
|
2009-11-07 19:18:03 +01:00
|
|
|
|
|
|
|
Alternatively, you can use the result of the ``completion`` command
|
2009-11-09 17:27:35 +01:00
|
|
|
directly with the eval function of you shell, e.g. by adding::
|
2009-11-07 19:18:03 +01:00
|
|
|
|
2010-08-10 12:56:57 +02:00
|
|
|
eval "`pip completion --bash`"
|
2009-11-09 17:27:35 +01:00
|
|
|
|
2009-12-01 22:50:10 +01:00
|
|
|
to your startup file.
|