Python Virtualenv Not Found? How to Install It Properly
If you’re working with Python, sooner or later you might see the dreaded error:
bash: virtualenv: command not foundOr in Windows PowerShell:
virtualenv : The term 'virtualenv' is not recognized as the name of a cmdletThis error means your system doesn’t know where to find the virtualenv command. It can happen for beginners and experienced developers alike—usually because virtualenv isn’t installed or isn’t added to your system’s PATH.
In this guide, we’ll break down:
- What
virtualenvis and why it’s important. - Why you might get the “Virtualenv not found” error.
- Step-by-step installation instructions for Windows, macOS, and Linux.
- How to verify and fix your installation.
- Common pitfalls and troubleshooting tips.
1. What is Virtualenv?
virtualenv is a Python tool that lets you create isolated environments for your projects.
Without it, installing packages affects your global Python installation, which can lead to version conflicts between projects.
Think of virtualenv as a sandbox where each project has its own dependencies and doesn’t interfere with others.
Example:
projectA/venv → Flask 1.1.2
projectB/venv → Flask 2.2.5Both projects can run different versions without clashing.
2. Why “Virtualenv Not Found” Happens
The error occurs when your terminal cannot find the virtualenv executable. Common causes include:
- Not Installed – You haven’t installed
virtualenvyet. - Wrong Python/Pip Version – Installed under a different Python version than the one you’re using.
- PATH Issues – Installed, but the executable folder isn’t in your system’s PATH.
- Using Python 3.3+ but Not Knowing About
venv– Modern Python includesvenvby default, butvirtualenvis still preferred in some workflows.
3. Installing Virtualenv Properly
Before installing, check your Python and pip versions:
python --version
pip --versionIf you have both python and python3, make sure you’re consistent—pip must match your Python version.
3.1 Install on Windows
- Open Command Prompt or PowerShell
(PressWin + R, typecmdorpowershell, then hit Enter). - Upgrade pip (optional but recommended):
python -m pip install --upgrade pip - Install virtualenv:
pip install virtualenv - Verify installation:
virtualenv --version
If the last command works, you’re done. If not, see the Troubleshooting section.
3.2 Install on macOS / Linux
- Open Terminal.
- Update pip:
python3 -m pip install --upgrade pip - Install virtualenv:
pip3 install virtualenv - Check installation:
virtualenv --version
4. Creating a Virtual Environment
Once installed, you can create a new virtual environment in your project folder:
virtualenv venvHere:
venvis the name of the environment folder (you can choose any name).
4.1 Activating the Environment
Windows (Command Prompt):
venv\Scripts\activateWindows (PowerShell):
venv\Scripts\Activate.ps1macOS/Linux:
source venv/bin/activateWhen activated, your terminal will show (venv) before the prompt.
4.2 Deactivating the Environment
deactivate5. Troubleshooting “Virtualenv Not Found” After Installation
If you still get the error after installing, try these fixes:
5.1 Make Sure Pip Matches Python
If you run:
python3 -m pip install virtualenvbut later type:
python -m virtualenv venvyou might be calling the wrong Python.
To fix:
- Always use the same version:
python3 -m virtualenv venvorpython -m virtualenv venv
5.2 Check PATH Environment Variables
On Windows:
- Press
Win + S, search for “Environment Variables”. - Edit your PATH.
- Ensure Python’s
Scriptsfolder is listed (e.g.C:\Users\<User>\AppData\Local\Programs\Python\Python39\Scripts).
On macOS/Linux:
- Add this to your
~/.bashrcor~/.zshrc:export PATH="$HOME/.local/bin:$PATH" - Reload shell:
source ~/.bashrc
5.3 Use Python’s Built-in venv
If installing virtualenv fails, Python 3.3+ includes venv by default:
python3 -m venv venvThis works almost identically.
6. Common Pitfalls
- Multiple Python versions – You might have Python 2.x and Python 3.x. Make sure you’re installing under the right version.
- Virtualenv inside another virtualenv – Avoid activating one virtual environment and then creating another inside it.
- Permissions errors – Use
--userflag if installing system-wide isn’t allowed:pip install --user virtualenv
7. Summary
When you see “Python Virtualenv Not Found”, it’s usually because:
- You haven’t installed it.
- You installed it under the wrong Python version.
- Your PATH isn’t set correctly.
Quick Fix:
pip install virtualenv
virtualenv venvAnd remember, Python’s built-in venv is always a fallback option.
✅ Final Tips:
- Always check
python --versionandpip --versionbefore installing. - If you switch between projects often, tools like Pipenv or Poetry might offer more convenience.
- Keep pip updated to avoid compatibility issues.

