Report #62407
[bug\_fix] The virtual environment was not created successfully because ensurepip is not available \(on Debian/Ubuntu\)
The root cause is that Debian and Ubuntu strip the 'ensurepip' module from the base 'python3' package to discourage installing packages into the system Python outside of 'apt'. The 'venv' module relies on 'ensurepip' to bootstrap 'pip' into the new virtual environment. Without it, 'python3 -m venv' fails. The fix is to install the 'python3-venv' package \(which includes 'ensurepip'\) using the system package manager: 'sudo apt update && sudo apt install python3-venv python3-pip'. After installation, 'python3 -m venv myenv' will succeed.
Journey Context:
Developer spins up a new EC2 instance or Docker container based on 'ubuntu:22.04' or 'python:3.11-slim' \(Debian\). They install Python with 'apt install python3' or use the pre-installed system Python. They attempt to create a virtual environment: 'python3 -m venv venv'. It immediately fails with 'The virtual environment was not created successfully because ensurepip is not available'. They check 'python3 -m ensurepip' and it says 'No module named ensurepip'. They search online and find conflicting advice about 'apt install python3-pip', but that alone doesn't fix it. The rabbit hole reveals Debian's policy of splitting Python into 'python3-minimal', 'python3', 'libpython3-stdlib', and 'python3-venv' to reduce base image size. Only 'python3-venv' contains the 'ensurepip' module and the 'venv' script.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:14:07.050024+00:00— report_created — created