Virtualenv Command Not Found
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
The virtualenv: command not found error means the virtualenv package is either not installed or installed in a location that is not on your system's PATH. The fix depends on your setup: install it with pip install virtualenv, use python -m virtualenv to bypass PATH issues, or switch to the built-in python -m venv module that requires no separate installation (Python 3.3+).
The Error
Fix 1: Install virtualenv
Fix 2: Use python -m virtualenv
If virtualenv is installed but not on PATH, invoke it through Python:
This works because python -m looks in Python's package directories, not the system PATH.
Fix 3: Use Built-In venv Instead (Recommended)
Python 3.3+ includes the venv module — no installation needed:
venv is the officially recommended tool for creating virtual environments in modern Python. It is lighter than virtualenv and ships with Python.
Fix 4: PATH Issues After pip install --user
When installed with --user, pip places executables in a user-local directory that may not be on PATH:
On macOS with Homebrew Python:
Fix 5: Multiple Python Versions
When multiple Python versions are installed, pip and pip3 may point to different versions:
Fix 6: System Package Manager
On some Linux distributions, install via the system package manager:
System packages avoid pip permission issues but may install older versions.
Fix 7: Windows-Specific
virtualenv vs venv
| Feature | venv | virtualenv |
| Installation | Built into Python 3.3+ | Requires pip install |
| Speed | Slower | Faster (caches packages) |
| Python 2 support | No | Yes |
| Multiple Python versions | Current version only | Can target any installed version |
--system-site-packages | Yes | Yes |
| Recommended for | Most projects | Legacy Python 2 or specific needs |
Verifying the Environment Works
Common Pitfalls
- Using
sudo pip install: This installs packages globally and can break system Python. Usepip install --user virtualenvor a virtual environment manager likepipxinstead. - Forgetting to activate: After creating a virtual environment, you must
source myenv/bin/activatebefore using it. Runningpip installwithout activating installs packages globally. .local/binnot on PATH:pip install --userputs binaries in~/.local/binwhich many shells do not include by default. Add it to your shell profile.- Confusing
virtualenvwithvenv: They do the same thing.venvis built-in and simpler.virtualenvis a third-party package with more features. For most projects,venvis sufficient. - Python version mismatch:
pip install virtualenvinstalls for whichever Pythonpipis linked to. If you have Python 3.9 and 3.11,pip3.11 install virtualenvensures it is installed for 3.11.
Summary
command not foundmeansvirtualenvis not installed or not on PATH- Install with
pip install virtualenvor usepython -m virtualenv - Use
python3 -m venv myenvinstead — it is built-in and requires no installation - Add
~/.local/binto PATH if usingpip install --user - On Linux, the system package manager (
apt,dnf) avoids pip permission issues venvis recommended for most projects;virtualenvfor Python 2 or multi-version needs

