Skip to main content

The pip command is a tool for installing and managing Python packages, such as those found in the Python Package Index. It's also a replacement for easy_install.

# To install a package (see 'pip install' for more install examples):
pip install <package_name>

# To upgrade a package:
pip install -U <package_name>

# To uninstall a package:
pip uninstall <package_name>

# To save installed packages to file:
pip freeze > <requirements.txt>

# To show installed package info:
pip show <package_name>

# --- pip-install (install Python packages)

# To install a package:
pip install <package_name>

# To install a specific version of a package:
pip install <package_name>==<package_version>

# To install packages listed in a file:
pip install -r <requirements.txt>

# To install packages from an URL or local file archive (.tar.gz | .whl):
pip install -f <url|path/to/file>

# To install the local package in the current directory in develop (editable) mode:
pip install -e .

# ---

# To install or upgrade pip, securely download <https://bootstrap.pypa.io/get-pip.py>,
# then run the following (which may require administrator access):
$ python get-pip.py
# See: <https://pip.pypa.io/en/latest/installing.html>

# Upgrade pip on Linux or OS X
$ pip install -U pip
# See: <https://pip.pypa.io/en/latest/installing.html>

# Upgrade pip on Windows
$ python -m pip install -U pip
# See: <https://pip.pypa.io/en/latest/installing.html>

# Search for a package
$ pip search Markdown

# Install a package
$ pip install Markdown

# Uninstall a package
$ pip uninstall Markdown

# Update an existing package
$ pip install Markdown --upgrade

# Show information about a pacakge
$ pip show Markdown

# List outdated packages
$ pip list --outdated

# Output and install packages in a requirement file
pip freeze > requirements.txt
pip install -r requirements.txt

# Uninstall a package without confirmation to remove (pipe "/usr/bin/yes")
/usr/bin/yes | pip3 uninstall flake8

# Upgrade all outdated packages, thanks to http://stackoverflow.com/a/3452888
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U

# Install specific version of a package
pip install -I SomePackage1==1.1.0 'SomePackage2>=1.0.4'