Python: pip Tutorial

By Xah Lee. Date: . Last updated: .

pip (package manager). pip is a is a command-line program used to {install, remove, update, …} software packages written in Python.

pip home page is at https://pypi.python.org/pypi/pip

Basic pip commands

◆ pip help

Usage:
  pip <command> [options]

Commands:
  install                     Install packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  zip                         DEPRECATED. Zip individual packages.
  unzip                       DEPRECATED. Unzip individual packages.
  bundle                      DEPRECATED. Create pybundles.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output.
  --log-file <path>           Path to a verbose non-appending log, that only logs failures. This
                              log is active by default at /Users/outbound/Library/Logs/pip.log.
  --log <path>                Path to a verbose appending log. This log is inactive by default.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore,
                              (w)ipe, (b)ackup.
  --cert <path>               Path to alternate CA bundle.
Install a package:

pip install ‹package name›==1.0

Show what files were installed:

$ pip show --files ‹package name›
  Name: ‹package name›
  Version: 1.0
  Location: /my/env/lib/pythonx.x/site-packages
  Files:
   ../somepackage/__init__.py
   [...]
List what packages are outdated:

$ pip list --outdated
  ‹package name› (Current: 1.0 Latest: 2.0)
Upgrade a package:

$ pip install --upgrade ‹package name›
  [...]
  Found existing installation: ‹package name› 1.0
  Uninstalling ‹package name›:
    Successfully uninstalled ‹package name›
  Running setup.py install for ‹package name›
  Successfully installed ‹package name›
Uninstall a package:

$ pip uninstall ‹package name›
  Uninstalling ‹package name›:
    /my/env/lib/pythonx.x/site-packages/somepackage
  Proceed (y/n)? y
  Successfully uninstalled ‹package name›

on Mac OS X, pip is at 〔/Library/Python/2.7/site-packages/pip-1.5.1-py2.7.egg/pip/〕

If you have a question, put $5 at patreon and message me.