'Error "virtualenv : command not found" but install location is in PYTHONPATH
This has been driving me crazy for the past 2 days.
I installed virtualenv on my Macbook using pip install virtualenv.
But when I try to create a new virtualenv using virtualenv venv, I get the error saying "virtualenv : command not found".
I used pip show virtualenv and the location of the installation is "Location: /usr/local/lib/python2.7/site-packages" but I can't figure out where the executable is. I tried dozens other similar looking posts but those solutions do not work for me.
Any ideas what might be going wrong here?
Solution 1:[1]
On macOS Mojave
First check python is in the path.python --version
Second check pip is installed.pip --version
If it is not installed.brew install pip
Third install virtualenvsudo -H pip install virtualenv
Solution 2:[2]
For Python 3
python3 -m virtualenv venv
Solution 3:[3]
As mentioned in the comments, you've got the virtualenv module installed properly in the expected environment since python -m venv allows you to create virtualenv's.
The fact that virtualenv is not a recognized command is a result of the virtualenv.py not being in your system PATH and/or not being executable. The root cause could be outdated distutils or setuptools.
You should attempt to locate the virtualenv.py file, ensure it is executable (chmod +x) and that its location is in your system PATH. On my system, virtualenv.py is in the ../Pythonx.x/Scripts folder, but this may be different for you.
Solution 4:[4]
Could it be that you are using Anaconda package manager? If so, then it has it's own virtual environment system which you setup as follows:
conda create --name venv
Solution 5:[5]
I had the same issue (although on ubuntu), a simple solution is instead of doing pip install virtualenv, you precede the commend with "sudo".
A little inspection reveals the reason behind this fix:

pip install virtualenv tries to put an executable under /usr/local/bin so that it can be invoked from command line, but it failed because only root has write permission to that directory
an alternative is pip install --user virtualenv, here are some further readings 1,2
Solution 6:[6]
Had the same problem on Windows. Command not found and can't find the executable in the directory given by pip show.
Fixed it by adding "C:\Users{My User}\AppData\Roaming\Python\Python39\Scripts" to the PATH environment variable.
Solution 7:[7]
I succeded creating manually a link to location/virtualenv.py in /usr/local/bin, naming it virtualenv and adding +x attribute on file
? ~ pip show virtualenv
Name: virtualenv
Version: 16.6.0
Summary: Virtual Python Environment builder
Home-page: https://virtualenv.pypa.io/
Author: Ian Bicking
Author-email: [email protected]
License: MIT
Location: /home/prsadev/.local/lib/python2.7/site-packages
Requires:
~ chmod +x /home/prsadev/.local/lib/python2.7/site-packages/virtualenv.py
~ sudo ln -sf /home/prsadev/.local/lib/python2.7/site-packages/virtualenv.py /usr/local/bin/virtualenv
Solution 8:[8]
I tried to have virtualenv at a random location & faced the same issue on a UBUNTU machine, when I tried to run my 'venv'. What solved my issue was :-
$virtualenv -p python3 venv
Also,instead of using $activate try :-
$source activate
If you look at the activate script(or $cat activate), you will find the same in comment.
Solution 9:[9]
Install virtualenv from https://pypi.org/project/virtualenv
python -m pip install --user virtualenv
sudo /usr/bin/easy_install virtualenv
Solution 10:[10]
This solved my similar problem!
You need to look online on how to create a virtual environement with python X.X.X (replace x.x.x with your python version)
mine was python 3.4.3 so bellow is how should i deal with it:
sudo python3 -m venv aramisvenv
Solution 11:[11]
I use asdf and had to do a reshim after installing virtualenv. asdf reshim
Fixed due to this response
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
