Skip to content

Python Virtualenv Not Found? How to Install It Properly

4 min read

If you’re working with Python, sooner or later you might see the dreaded error:

bash: virtualenv: command not found

Or in Windows PowerShell:

virtualenv : The term 'virtualenv' is not recognized as the name of a cmdlet

This 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 virtualenv is 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.5

Both 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:

  1. Not Installed – You haven’t installed virtualenv yet.
  2. Wrong Python/Pip Version – Installed under a different Python version than the one you’re using.
  3. PATH Issues – Installed, but the executable folder isn’t in your system’s PATH.
  4. Using Python 3.3+ but Not Knowing About venv – Modern Python includes venv by default, but virtualenv is still preferred in some workflows.

3. Installing Virtualenv Properly

Before installing, check your Python and pip versions:

python --version
pip --version

If you have both python and python3, make sure you’re consistent—pip must match your Python version.


3.1 Install on Windows
  1. Open Command Prompt or PowerShell
    (Press Win + R, type cmd or powershell, then hit Enter).
  2. Upgrade pip (optional but recommended): python -m pip install --upgrade pip
  3. Install virtualenv: pip install virtualenv
  4. Verify installation: virtualenv --version

If the last command works, you’re done. If not, see the Troubleshooting section.


3.2 Install on macOS / Linux
  1. Open Terminal.
  2. Update pip: python3 -m pip install --upgrade pip
  3. Install virtualenv: pip3 install virtualenv
  4. Check installation: virtualenv --version

4. Creating a Virtual Environment

Once installed, you can create a new virtual environment in your project folder:

virtualenv venv

Here:

  • venv is the name of the environment folder (you can choose any name).

4.1 Activating the Environment

Windows (Command Prompt):

venv\Scripts\activate

Windows (PowerShell):

venv\Scripts\Activate.ps1

macOS/Linux:

source venv/bin/activate

When activated, your terminal will show (venv) before the prompt.


4.2 Deactivating the Environment
deactivate

5. 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 virtualenv

but later type:

python -m virtualenv venv

you might be calling the wrong Python.

To fix:

  • Always use the same version: python3 -m virtualenv venv or python -m virtualenv venv

5.2 Check PATH Environment Variables

On Windows:

  1. Press Win + S, search for “Environment Variables”.
  2. Edit your PATH.
  3. Ensure Python’s Scripts folder is listed (e.g. C:\Users\<User>\AppData\Local\Programs\Python\Python39\Scripts).

On macOS/Linux:

  • Add this to your ~/.bashrc or ~/.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 venv

This 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 --user flag 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 venv

And remember, Python’s built-in venv is always a fallback option.


✅ Final Tips:

  • Always check python --version and pip --version before installing.
  • If you switch between projects often, tools like Pipenv or Poetry might offer more convenience.
  • Keep pip updated to avoid compatibility issues.