All notes


What is pip's full name? I don't find any definition online, but this "The PyPA recommended tool for installing and managing Python packages." from pip website.(PyPA: Python Parser) So pip is just a command line tool to manage python packages, which is to say, it is not a python command! And you can't run it directly from python!

On windows, to use pip, you need to add the path: Python2/Scripts (pip.exe resides in it).

StackOverflow: download-only.

# Upgrade pip itself. It also works in windows cmd.
pip install -U pip
# Windows version
python -m pip install -U pip

pip install SomePackage==1.0.4     # specific version
pip install 'SomePackage>=1.0.4'     # minimum version

pip uninstall somePackage

pip list
pip list --outdated
pip show somePackege
pip search "query"

# -d, --download
pip install -d /somePath package

# Install offline.
# --no-index: Ignore package index (only looking at --find-links URLs instead).
# -f, --find-links url: If a url or path to an html file, then parse for links to archives. If a local path or file:// url that's a directory,then look for archives in the directory listing.
pip install --no-index -f /somePath package

pip install ./downloads/SomeProject-1.0.4.tar.gz

# Or install from the requirement
# -r, --requirement
pip install -d /somePath -r requirementFile


pip freeze
# docutils==0.11
# Jinja2==2.7.2
# MarkupSafe==0.19
# Pygments==1.6
# Sphinx==1.2.2

# Generate a requirements file:
pip freeze > requirements.txt

# Install from it:
pip install -r requirements.txt

pip.conf user guide.

File location

If multiple configuration files are found by pip then they are combined in the following order:

  1. Firstly the site-wide file is read, then
  2. The per-user file is read, and finally
  3. The virtualenv-specific file is read.

Each file read overrides any values read from previous files, so if the global timeout is specified in both the site-wide file and the per-user file then the latter value is the one that will be used.


The names of the settings are derived from the long command line option, e.g. if you want to use a different package index (--index-url) and set the HTTP timeout (--default-timeout) to 60 seconds your config file would look like this:

timeout = 60
index-url =

Decreasing the timeout to 10 seconds when running the freeze (Freezing Requirements) command and using 60 seconds for all other commands is possible with:

timeout = 60
timeout = 10

Boolean options like --ignore-installed or --no-dependencies can be set like this:

ignore-installed = true
no-dependencies = yes

To enable the boolean options --no-compile and --no-cache-dir, falsy values have to be used:

no-cache-dir = false

no-compile = no

Appending options like --find-links can be written on multiple lines:

find-links =

find-links =

Change pypi host


pip install -i http://mirrorURL/simple packageName --trust-host mirrorURL
pip install -i django --trusted-host

To permanently add the customized pypi host, add in ~/.config/pip/pip.conf:

timeout = 10
index-url =
trusted-host =

Environment Variables

pip's command line options can be set with environment variables using the format PIP_"UPPER_LONG_NAME" . Dashes (-) have to be replaced with underscores (_). For example, to set the default timeout:


## This is the same as passing the option to pip directly:
pip --default-timeout=60 [...]

To set options that can be set multiple times on the command line, just add spaces in between values. For example:

export PIP_FIND_LINKS=""

# Is the same as calling:
pip install --find-links= --find-links=

Config Precedence

Precedence from high to low:

  1. Command line options
  2. Environment variables
  3. The config file. Within the config file, command specific sections have precedence over the [global] section.


--host=foo overrides PIP_HOST=foo
PIP_HOST=foo overrides a config file with [global] host = foo



pip comes with support for command line completion in bash and zsh.

# To setup for bash:
pip completion --bash >> ~/.profile

# To setup for zsh:
pip completion --zsh >> ~/.zprofile

Alternatively, you can use the result of the completion command directly with the eval function of your shell, e.g. by adding the following to your startup file:

eval "`pip completion --bash`"


pip install --help

# --user: Install to ~/.local/, or %APPDATA%\Python on Windows
# -U, --upgrade: Upgrade all specified packages
pip install awscli --upgrade --user

Installing from local packages

# Download the archives that fulfill your requirements:
pip install --download DIR -r requirements.txt

# If some of your requirements don't come as wheels from PyPI, and you want wheels, then run this instead:
pip wheel --wheel-dir DIR -r requirements.txt

# To install from local only:
pip install --no-index --find-links=DIR -r requirements.txt

PyPI mirrors and caches

ReadTheDocs: mirrors.


readTheDocs: pip wheel.

Wheel is a built-package format, and offers the advantage of not recompiling your software during every install.

'pip wheel' uses the bdist_wheel setuptools extension from the wheel package to build individual wheels.

# Build wheels for a requirement (and all its dependencies), and then install
# -w, --wheel-dir
pip wheel --wheel-dir=/tmp/wheelhouse SomePackage
pip install --no-index --find-links=/tmp/wheelhouse SomePackage