Affected versions: Ubuntu 24.04 LTS

πŸ“– ~1 min read

Table of contents
  1. Symptom & Impact
  2. Environment & Reproduction
  3. Root Cause Analysis
  4. Quick Triage
  5. Step-by-Step Diagnosis
  6. Solution – Primary Fix
  7. Solution – Alternative Approaches
  8. Verification & Acceptance Criteria
  9. Rollback Plan
  10. Prevention & Hardening
  11. Related Errors & Cross-Refs
  12. References & Further Reading

Symptom & Impact

python3 -m venv fails, blocking isolated dependency setup for projects.

Environment & Reproduction

Minimal Ubuntu installs may not include venv module by default.

python3 --version
python3 -m venv .venv

Root Cause Analysis

python3-venv package is missing or tied to a different Python minor version.

Quick Triage

Check installed Python packages and module availability.

dpkg -l | grep python3-venv
python3 -m ensurepip --version 2>/dev/null || true

Step-by-Step Diagnosis

Identify active Python interpreter and matching venv package.

which python3
python3 -c 'import sys; print(sys.version)'
apt-cache policy python3-venv
Illustrative mockup for ubuntu-24-04-lts β€” terminal_or_shell
Diagnostic output for python/venv-missing β€” Illustrative mockup β€” Progressive Robot

Solution – Primary Fix

Install python3-venv and recreate the virtual environment.

Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.

sudo apt update
sudo apt install python3-venv -y
python3 -m venv .venv
source .venv/bin/activate
Illustrative mockup for ubuntu-24-04-lts β€” log_or_console
Resolution output for python/venv-missing β€” Illustrative mockup β€” Progressive Robot

Solution – Alternative Approaches

Use virtualenv from pipx if project standards require custom tooling.

sudo apt install pipx -y
pipx install virtualenv
virtualenv .venv

Verification & Acceptance Criteria

Virtual environment activates and isolated pip installs work.

source .venv/bin/activate
python -m pip --version

Rollback Plan

Remove malformed virtual environment and rebuild cleanly.

rm -rf .venv
python3 -m venv .venv

Prevention & Hardening

Add python3-venv to base image packages for development hosts.

sudo apt-mark manual python3-venv

Related errors include ensurepip is not available and No module named venv.

Related tutorial: View the step-by-step tutorial for Ubuntu 24.04 LTS.

View all Ubuntu 24.04 LTS tutorials on the Tutorials Hub β†’

Browse all common problems & solutions on the Tutorials Hub.

References & Further Reading

Python venv documentation and Ubuntu Python package guide.

Need Expert Help?

If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today β€” we respond within one business day.