Last Updated: February 25, 2016
·
16.52K
· dhaffner

Tell pip to use a mirror

When a plain pip install fails at the package download step, try one of the PyPI mirrors.

One can tell pip to try mirrors until it finds a package by passing a parameter in:

pip install --use-mirror <package_name>

I was trying to install lxml but the tar download would timeout and cause pip to fail. Trying the above flag only resulted in the same error since pip 'found' the package at the first mirror it checked. Therefore I needed to explicitly try a different mirror, like so:

pip install -i http://b.pypi.python.org/simple <package_name>

This worked for me. It's a good tip to keep in mind to avoid a bunch of yak shaving just to get a dependency installed.