← All notes

Python ensurepip: bootstrap pip into an existing install

Answer: The ensurepip package bootstraps the pip installer into an existing Python installation or virtual environment.

What it does

It was added in version 3.4.

Pip is an independent project with its own release cycle, so CPython bundles a stable copy and bootstraps it this way.

End users usually do not need to run the module, because pip should already be bootstrapped by default.

A direct run may still be needed if the installer was skipped, or after pip was explicitly uninstalled.

This module does not access the internet. The components needed to bootstrap pip are included as internal parts of the package.

How to run it

The command line interface is invoked with the interpreter's -m switch.

Running python -m ensurepip installs pip when it is missing, and otherwise does nothing.

By default, pipX and pipX.Y scripts are installed. X.Y stands for the version of Python used to invoke ensurepip.

A --default-pip request also installs a pip script beside those two.

An --altinstall request skips the pipX script. Providing both of the script selection options will trigger an exception.

The version function returns a string for the pip release that will be installed during a bootstrap.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, ensurepip — Bootstrapping the pip installer; CPython, ensurepip documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, ensurepip — Bootstrapping the pip installer; CPython, ensurepip documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:ccjrafax

iinventedlight. 2026. "Python ensurepip: bootstrap pip into an existing install." iinventedlight Library, iil:note:ccjrafax, version of 2026-11-26. https://iinventedlight.com/library/notes/python-ensurepip/. License: CC-BY-4.0.

@misc{iil_note_ccjrafax,
  author = {{iinventedlight}},
  title = {{Python ensurepip: bootstrap pip into an existing install}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-26},
  url = {https://iinventedlight.com/library/notes/python-ensurepip/},
  note = {Permanent ID iil:note:ccjrafax. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-ensurepip.md.