A new Python virtual environment on Ubuntu comes without pip
Your error
The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3-venv package using the following command.2 more lines it can showFix it fast
Most common cause, 1 of 3The python3-venv package is missing
Install python3-venv.
sudo apt update
sudo apt install python3-venv
rm -rf .venv
python3 -m venv .venvShort answer
On Ubuntu 24.04 and 26.04, python3 -m venv stops with 'ensurepip is not available' because the pip bootstrap ships in a separate apt package (python3.12-venv or python3.14-venv). Install python3-venv, delete the half-made folder and create it again. A venv made with uv venv or --without-pip has no pip either; add it with python -m ensurepip.
Which cause do you have?
Check two things: whether the ensurepip module exists on the system, and whether the venv folder holds a pip script. No ensurepip file means cause 1; ensurepip present but no pip in .venv/bin means cause 2; pip present in .venv/bin means cause 3.
ls /usr/lib/python3*/ensurepip/__main__.py
ls .venv/bin/ | grep -i pipThen find the line you see in this list and open its fix:
- 1The python3-venv package is missing
python3 -m venv prints the ensurepip message, and the ls of /usr/lib/python3*/ensurepip finds no file - 2The venv was made by uv venv or with --without-pip
Creating the venv printed no error, but .venv/bin holds python and the activate scripts and nothing named pip - 3The pip being run is not the one inside the venv
pip exists in .venv/bin, yet which pip prints /usr/bin/pip or nothing at all
What does the error look like?
The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3-venv package using the following command.apt install python3.12-venvensurepip is disabled in Debian/Ubuntu for the system python.
Cause 1 of 3
The python3-venv package is missing
You seepython3 -m venv prints the ensurepip message, and the ls of /usr/lib/python3*/ensurepip finds no file
Check
The 'ensurepip is not available' message comes from Ubuntu's own patch to the venv module, which prints it when ensurepip/__main__.py is absent from the standard library. On Ubuntu 24.04 that file is part of python3.12-venv, and the same package depends on python3-pip-whl, the pip wheel that venv installs into each new environment.
apt-cache policy python3-venvFix
Install python3-venv. It depends on the venv package for your release's default Python, so the same command works on 24.04 and 26.04. Then delete the folder left by the failed run and build it again, as the message itself asks.
sudo apt update
sudo apt install python3-venv
rm -rf .venv
python3 -m venv .venvVerify
The new .venv/bin folder lists pip, and pip reports a path inside .venv.
.venv/bin/python -m pip --versionConfirmed by git.launchpad.net
Cause 2 of 3
The venv was made by uv venv or with --without-pip
You seeCreating the venv printed no error, but .venv/bin holds python and the activate scripts and nothing named pip
Check
An empty environment like this is expected, not broken. python3 -m venv --without-pip skips the pip bootstrap on purpose, and uv venv puts pip in only when you pass --seed. Ubuntu's ensurepip block applies to the system interpreter alone, so bootstrapping from inside the venv is allowed once python3-venv is installed.
ls -l .venv/binFix
Bootstrap pip with the venv's own interpreter. In a uv project, either recreate the venv with --seed or leave pip out and install packages through uv pip install.
.venv/bin/python -m ensurepip --upgrade
# uv alternatives
rm -rf .venv && uv venv --seed
uv pip install requestsVerify
pip now sits in .venv/bin and pip --version points into the venv.
.venv/bin/python -m pip --versionConfirmed by docs.python.org
Cause 3 of 3
The pip being run is not the one inside the venv
You seepip exists in .venv/bin, yet which pip prints /usr/bin/pip or nothing at all
Check
Activation is what puts .venv/bin at the front of PATH, so a bare pip command reaches the venv only in a shell where the activate script ran. A fresh terminal, a cron job or a systemd unit still finds the system pip first on PATH, or no pip at all, even though the venv is fine.
which -a pip python3Fix
Activate the venv in every new shell, or skip activation and call the venv's interpreter by its full path; the Python docs say that works the same way.
source .venv/bin/activate
python -m pip install requests
# no activation needed
.venv/bin/python -m pip install requestsVerify
After activation, which pip shows a path under .venv/bin.
which pipConfirmed by docs.python.org
How do I stop it coming back?
- List python3-venv beside python3 in the apt step of your server setup script or Dockerfile.
- In scripts, cron jobs and systemd units, call .venv/bin/python -m pip rather than a bare pip.
- When the team uses uv but some tools still expect pip in the venv, set UV_VENV_SEED=1 so uv venv always seeds it.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: stegnor.com, Menulo, ShopGo.