Skip to content

Pip issue: No module named 'ensurepip'

When you create a virtual environment, you might encounter the following error: ModuleNotFoundError: No module named 'ensurepip'

Text Only
Error: Command '['/home/kc/Desktop/projects/pretty/venv/bin/python3.11', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

The error indicates that the ensurepip module failed to set up pip in your virtual environment. This can happen if the Python installation is incomplete or corrupted, or if the virtual environment was not created properly.

Step 1: Ensure Python is Properly Installed

Bash
python3.11 --version
python3.11 -m ensurepip --version

Step 2: If the above commands fail, reinstall Python 3.11

Bash
sudo apt update
sudo apt install --reinstall python3.11 python3.11-venv python3.11-dev

Step 3: Recreate the virtual environment

Bash
python3.11 -m venv venv