What to do when PyPI goes down
Lately PyPI, the Python package index, has been having some availability issues. When PyPI goes down it really hurts Python developers: we can’t install new packages, bring up new development environments or virtualenvs, or deploy code with depedencies.
Work is ongoing – see
PEP 381 – to add much-needed
resiliency to PyPI, and the fruits of these labors are starting to
become available. In particular, a number of PyPI mirrors are now
d.pypi.python.org are up and running. Each mirror has fairly
up-to-date copies  of all the packages and metadata on
|||Exactly how often each mirror updates is up to the maintainer. Each mirror maintains a last-modified file that informs you when the mirror was last updated; it’s at |
They’re not totally perfect clones – the public parts of the web interface aren’t on the clones – but they have everything that package installation tools need. This means that when PyPI goes down, you can make a few tweaks, switch to a mirror, and get on with your day.
In the future I expect most Python packaging tools will gain native, transparent support for failing over to these mirrors, but for now you’ll need to manually do so. All of the Python packaging tools support mirrors, each in a slightly different way:
If you’re using a recent
pip (0.8.1 or later) use the
pip install --use-mirrors $PACKAGE
You can also set the
PIP_USE_MIRRORS environment variable.
This’ll automatically query the list of mirrors and keep trying until one responds. It can take a bit of time when PyPI’s down as it waits for PyPI to time out, but it’ll work.
For older versions of
pip, or if you want to force the use of a
particular mirror, use:
pip install -i http://d.pypi.python.org/simple $PACKAGE
If you want to instruct
pip to always use the mirror – good if
you’ll be doing a lot of installation, or if you’re using
pip as part
of a bigger automation tool – then put:
[global] index-url = http://d.pypi.python.org/simple
easy_install to boostrap a new
environ, so simply making the
pip changes isn’t enough to allow you to
create new virtualenvs when PyPI is down.
Instead, you’ll need to make the global change to
desribed. under easy_install, below.
To use a mirror with Buildout, add:
[buildout] index = http://d.pypi.python.org/simple
To use the mirror globally in any Buildout on your system, put those
same lines above into
If you need to run a Buildout
bootstrap.py, note that it currently
easy_install as part of the bootstrap procedure, so you’ll need
to add the lines to
~/.pydistutils.cfg described below.
pip, I expect that Buildout will eventually gain native mirror
Really, you shouldn’t be using
easy_install any more – please
If you must, though, you can use a mirror with
easy_install -i http://d.pypi.python.org/simple $PACKAGE
easy_install use a mirror globally, put:
[easy_install] index_url = http://d.pypi.python.org/simple
Because ``easy_install`` is no longer under active development, I
don’t expect ``easy_install`` to ever gain native mirror
support. Once again, you should switch to ``pip``.
I’m informed by PJ Eby, the maintainer of
easy_install, that those projects aren’t quite dead yet and that he’s
got plans to add mirroring support to
I apologize for getting my facts wrong about the state of
Still, I suggest that folks switch to
pip: it’s got a larger
development community, more active forward progress, and it’s a better
tool in general.
As I’ve been saying, the next steps here are to add support for automatic failover to a mirror. PEP 381 describes the mirroring protocol and the validation procedure client libraries should take to determine which mirrors exist and which are valid.
I expect that the maintainers of the various packaging tools are working on this problem, but I’m also sure that patches to distribute, pip, virtualenv, and Buildout (and any other tool that requires PyPI to run) would be more than welcome.