LinuxCommandLibrary

pip3

Install Python packages

TLDR

Install a package

$ pip3 install [package]
copy

Install a specific version of a package
$ pip3 install [package]==[version]
copy

Upgrade a package
$ pip3 install [[-U|--upgrade]] [package]
copy

Uninstall a package
$ pip3 uninstall [package]
copy

Save the list of installed packages to a file
$ pip3 freeze > [requirements.txt]
copy

Install packages from a file
$ pip3 install [[-r|--requirement]] [requirements.txt]
copy

Show installed package info
$ pip3 show [package]
copy

SYNOPSIS

pip3 command [options]

PARAMETERS

install
    Install packages from PyPI or a local file. Can specify package names directly, or provide a requirements file.

uninstall
    Uninstall one or more packages.

list
    List installed packages.

show
    Show information about installed packages.

search
    Search PyPI for packages matching a query.

download
    Download packages without installing them.

wheel
    Build wheels from your requirements.

hash
    Compute hashes of package archives.

completion
    A helper command used for command completion.

help
    Show help for commands.

-v, --verbose
    Give more output.

-q, --quiet
    Give less output.

--no-cache-dir
    Disable caching of wheels and HTTP responses.

-r, --requirement
    Install from the given requirements file.

-U, --upgrade
    Upgrade all specified packages to the newest available version.

DESCRIPTION

pip3 is a package management system used to install and manage software packages written in Python. It's specifically designed for Python 3 environments. pip3 connects to the Python Package Index (PyPI), a repository of thousands of third-party Python modules.
It allows you to easily download, install, upgrade, and uninstall packages, resolving dependencies automatically. pip3 simplifies the process of adding external functionality to your Python projects, enabling you to leverage existing code and libraries rather than writing everything from scratch. It uses the 'wheel' format for installations, promoting faster and more reliable package deployments.
Using pip3 promotes code reusability and makes Python development faster and more efficient by streamlining package management. It's an essential tool for any Python 3 developer.

CAVEATS

Requires Python 3 to be installed. Must be used with the correct Python version (pip for Python 2, pip3 for Python 3). Requires network access to download packages from PyPI unless packages are locally available.

REQUIREMENTS FILES

Requirements files are plain text files that specify a list of packages and their versions to be installed. They are typically named 'requirements.txt'. You can install packages from a requirements file using 'pip3 install -r requirements.txt'.

VIRTUAL ENVIRONMENTS

It is highly recommended to use virtual environments when working with Python projects. Virtual environments isolate project dependencies, preventing conflicts between different projects. Use the 'venv' module (e.g., 'python3 -m venv myenv') to create virtual environments, and then activate them before using pip3.

HISTORY

pip emerged as a superior alternative to easy_install for Python package management. As Python 3 gained prominence, pip3 was created to specifically manage packages for Python 3 environments. The development of pip3 ensured compatibility and optimized package management within the Python 3 ecosystem. It addressed limitations of earlier tools and improved the overall developer experience by providing a more robust and user-friendly interface for managing Python packages.

SEE ALSO

python3(1), easy_install(1)

Copied to clipboard