pip

term

programming

Kept in this browser · My desk

The package installer for Python, which installs packages from the Python Package Index and other indexes into the environment of the interpreter that runs it.

Run it as python -m pip, so that the interpreter, and with it the environment, is explicit. Each virtual environment gets its own copy, bootstrapped by ensurepip, so updating Python does not update the pip inside environments that already exist; the Python 3.13.17 release notes of October 2026 asked users to upgrade pip in every existing environment for that reason. pip's documentation warns that by default it does not protect against remote tampering and runs code from distributions; --require-hashes and --only-binary :all: change that.

The name is its own description. On 28 October 2008 Ian Bicking announced that he had finished renaming his installer pyinstall to pip, and explained the new name as an acronym and a declaration: pip installs packages. The project's documentation still opens with the same sentence in other words, the package installer for Python, used to install from the Python Package Index (PyPI) and other indexes. That scope is the first thing to get right. pip installs, removes and lists distributions in one Python environment; it does not create environments (venv does), does not install or select Python versions, and by its own account does not verify what it installs unless told to.

pip is not part of the standard library, yet almost every Python has it. PEP (Python Enhancement Proposal) 453, written by Donald Stufft and Alyssa Coghlan and created on 10 August 2013, made pip the officially recommended installer and had Python 3.4 provide it by default, preferring it to its predecessor easy_install, whose design problems could not be fixed without breaking compatibility. The mechanism is the ensurepip module: each maintenance and feature release of CPython bundles the latest stable pip as a private copy, and ensurepip installs that copy into an installation or a new virtual environment without accessing the internet. The PEP is explicit that pip stays external to CPython, maintained by the Python Packaging Authority (PyPA). Two things follow. The pip in an environment is as old as the Python that created the environment, and python -m pip install --upgrade pip is the normal way to refresh it. And a pip problem can force a Python release: 3.13.17, of 21 October 2026, was a special security release whose purpose was to raise the embedded pip to 26.2.2, because that pip carries a newer copy of the certifi root-certificate bundle, after a certificate authority incident.

Versions follow the calendar. A version number has the form YY.N, where the first number is the year and the second identifies the quarter, with releases planned for January, April, July and October and a deprecation period of at least six months for documented behaviour. Version 1.0 dates from 4 April 2011; support for Python 2 ended with pip 21.0; pip 26.1 dropped Python 3.9; and the changelog read on 12 November 2026 ends at 26.3, released on 2 November 2026.

An install is a search, a resolution and an unpacking. pip looks for candidates on PyPI, or on the index given with --index-url (the default is https://pypi.org/simple), in local directories, and in any location added with --find-links or --extra-index-url; there is no priority among these places, and the best match by version wins. It then resolves dependencies, which it can only learn by downloading distribution files; since version 20.3 the resolver backtracks when an earlier choice turns out to be incompatible, which is why a long install sometimes shows several versions of the same package being fetched. A wheel is unpacked into site-packages; a source distribution is first built into a wheel by the project's build system, on the installing machine. Two caches, on by default since 6.0, shorten the next run: one for HTTP (Hypertext Transfer Protocol) responses, which behaves like a browser cache, and one for wheels built locally. Everything lands in the environment of the interpreter that runs pip, which is why the user guide spells the command as python -m pip (py -m pip on Windows): the interpreter named is the one that receives the packages.

The command set is small. install, uninstall, list, show, freeze, check and inspect manage and describe an environment; download, wheel and hash handle distribution files; index and search query an index; cache, config and debug concern pip itself; lock, still experimental, writes the standard pylock.toml lock file. A requirements file passed with -r lists what to install, and a constraints file passed with -c only limits versions: naming a package there does not install it, which makes one constraints file usable across an organization. pip freeze prints the environment in requirements format, but PyPI's own incident guidance points out that this is not a lock file, because a lock must carry the hashes of the archives.

Behaviour can be set in three places: on the command line, in environment variables (each option has one, formed with the PIP_ prefix) and in configuration files in INI format at three levels, global (/etc/pip.conf), per user (pip.conf under .config/pip in the home directory) and per environment (pip.conf at the root of the virtual environment), named pip.ini on Windows. The network options are the ones an operations team ends up reading. --proxy takes a proxy URL (Uniform Resource Locator) with optional credentials; --timeout defaults to 15 seconds and --retries to 5. pip has verified HTTPS certificates by default since version 1.3. --cert, or PIP_CERT, points it at a bundle of certificate authority certificates, and since 24.2 pip also trusts the operating system's certificate store, in addition to its bundled certifi list, through the truststore library. That change is what lets pip work behind a proxy that inspects TLS (Transport Layer Security) and re-signs traffic with a private authority the machine already trusts; before it, the authority had to be passed to pip explicitly. --trusted-host does the opposite of all this, accepting a host without valid HTTPS, and belongs in no permanent configuration.

The security defaults are stated without comfort in pip's documentation: by default pip does not perform any checks to protect against remote tampering, and installing involves running arbitrary code from distributions. Hash-checking mode, available since 8.0, answers the first half. A requirement line carries one or more --hash values, and once any line has one the mode is on for all: every requirement and every dependency must be pinned with == and hashed, sha256 being the recommended algorithm, while md5, sha1 and sha224 are refused. The hash an index puts in a download URL does not count, since it comes from the same remote source and only detects a corrupted download. --only-binary :all: answers the second half by refusing source distributions, so that no build code runs, although the 26.3 changelog adds that pip has never considered installing untrusted wheels safe, because Python's import system is dynamic (release 25.0 had fixed a bug that let a crafted wheel execute code during installation). Two more options address the index. pip's documentation calls --extra-index-url unsafe for private packages, the dependency confusion case, and --uploaded-prior-to, added in 26.0 and accepting durations such as P3D since 26.1, ignores releases newer than a given age on indexes that publish upload times.

pip also refuses on purpose. Since 23.0 it reads the EXTERNALLY-MANAGED marker that PEP 668 lets a Linux distribution place in its Python, and outside a virtual environment it stops with an error unless --break-system-packages is given (added in 23.0.1); --require-virtualenv makes the same refusal a local policy. Its neighbours cover what it leaves out: pipx installs command-line applications, each in its own virtual environment, where pip installs into whatever environment is active with no isolation; uv, which like PDM and Poetry also uses PyPI by default, requires a virtual environment unless told otherwise. And pip reports little about its user: it collects no telemetry, but each request tells the index the Python version and operating system in use.

Also known as: python -m pip, pip install

Sources

← Back to P Back to the glossary