pip3
Install Python packages
TLDR
Install a package
Install a specific version of a package
Upgrade a package
Uninstall a package
Save the list of installed packages to a file
Install packages from a file
Show installed package info
SYNOPSIS
pip3 [<general options>] <command> [<command options>] [<arguments>]
PARAMETERS
-h, --help
Show help message for pip3 or a specific command.
--version
Show pip version and exit.
-v, --verbose
Give more output. Option is additive, and can be used up to 3 times.
-q, --quiet
Give less output.
--log <path>
Path to a verbose log file.
--proxy <url>
Specify an HTTP proxy in the form user:passwd@proxy.server:port.
--timeout <seconds>
Set the socket timeout for network operations (default 15 seconds).
--retries <times>
Specify the number of retries for network errors (default 5).
--no-input
Do not prompt for input of any kind.
DESCRIPTION
pip3 is the standard package management system used to install and manage software packages written in Python 3.
It connects to the Python Package Index (PyPI), a large repository of Python software, and allows users to easily download, install, upgrade, and uninstall Python packages and their dependencies.
While pip3 is a command-line utility, it is often recommended to invoke it via python3 -m pip to ensure that you are using the pip instance associated with your specific Python 3 interpreter, especially when multiple Python versions are present on a system. This helps prevent conflicts and ensures that packages are installed into the correct environment.
pip3 plays a crucial role in the Python ecosystem, enabling developers to easily share and reuse code by managing project dependencies efficiently.
CAVEATS
Using pip3 install with sudo (i.e., installing packages globally) is generally discouraged as it can interfere with system-managed Python packages and lead to conflicts. It's highly recommended to use virtual environments (created with python3 -m venv) for project-specific dependencies, or install packages to the user site directory with pip3 install --user for personal use. Recent versions of pip also introduced a --break-system-packages flag to explicitly acknowledge modifications to system Python, making it harder to accidentally corrupt the system Python installation.
RECOMMENDED INVOCATION
While pip3 is a common command, the most robust way to invoke pip for Python 3 is python3 -m pip. This ensures that the pip module from the specific python3 interpreter being used is executed, preventing potential issues when multiple Python versions or virtual environments are active.
KEY SUBCOMMANDS
Some of the most frequently used pip3 subcommands include:
- install: Installs packages from PyPI or other sources.
- uninstall: Removes installed packages.
- list: Lists installed packages.
- freeze: Outputs installed packages in requirements format.
- show: Shows information about installed packages.
- check: Verify installed packages have compatible dependencies.
VIRTUAL ENVIRONMENTS
For development, it's highly recommended to use virtual environments (e.g., with python3 -m venv or virtualenv). A virtual environment creates an isolated Python installation, allowing you to install packages for a specific project without affecting the global Python installation or other projects. This prevents dependency conflicts and ensures project portability.
HISTORY
pip, originally called pyinstall, was created by Ian Bicking in 2008 as a replacement for easy_install. Its name is a recursive acronym, "Pip Installs Packages." The pip3 variant emerged with the widespread adoption of Python 3 to specifically target Python 3 environments, distinct from Python 2 installations that often used just pip.
Since Python 3.4, pip (and by extension pip3) has been included by default with Python distributions, establishing it as the official and de-facto standard package installer for the language. It is actively maintained and developed by the Python Packaging Authority (PyPA).
SEE ALSO
python3(1), virtualenv(1), apt(8)