Skip to content
Latchkey

Python "No module named pip" - Restore pip in CI

The interpreter you are calling has no pip available. Either pip was never installed for this Python, a venv was created without it, or PATH is resolving the wrong interpreter.

What this error means

Running pip reports "command not found", or python -m pip reports "No module named pip". The interpreter itself works; it just has no pip module installed.

Terminal
/usr/bin/python3: No module named pip
# or
pip: command not found

Common causes

Minimal Python without pip

Some base images ship the interpreter but not pip to keep the image small. python3 runs, but the pip module is absent.

venv created with --without-pip

A virtual environment built with --without-pip (or on a system where ensurepip is disabled) has no pip inside it.

How to fix it

Bootstrap pip with ensurepip

ensurepip ships with CPython and reinstalls pip into the current interpreter.

Terminal
python3 -m ensurepip --upgrade
python3 -m pip --version

Install the distro pip package

On Debian/Ubuntu where ensurepip is stripped, install pip via apt.

Terminal
apt-get update && apt-get install -y python3-pip

Always call pip via the interpreter

  1. Use python -m pip ... so pip matches the active interpreter, not whatever pip is first on PATH.
  2. Confirm with python -m pip --version which Python and which pip you are using.

How to prevent it

  • Use a base image that includes pip, or run ensurepip early in the job.
  • Create venvs without --without-pip.
  • Invoke pip as python -m pip consistently in CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →