Virtualenv Command Not Found
Solution 1
If you installed it with
pip install virtualenv
You need to run
sudo /usr/bin/easy_install virtualenv
which puts it in /usr/local/bin/
.
The above directory by default should be in your PATH
; otherwise, edit your .zshrc
(or .bashrc
) accordingly.
Solution 2
I faced the same issue and this is how I solved it:
- The issue occurred to me because I installed virtualenv via pip as a regular user (not root). pip installed the packages into the directory
~/.local/lib/pythonX.X/site-packages
- When I ran pip as root or with admin privileges (sudo), it installed packages in
/usr/lib/pythonX.X/dist-packages
. This path might be different for you. - virtualenv command gets recognized only in the second scenario
- So, to solve the issue, do
pip uninstall virtualenv
and then reinstall it withsudo pip install virtualenv
(or install as root)
Solution 3
The simplest answer. Just:
pip uninstall virtualenv
and then:
pip install virtualenv
Or you maybe installed virtualenv with sudo
, in that case:
pip install --user virtualenv
Solution 4
On Ubuntu 18.04 LTS I also faced same error. Following command worked:
sudo apt-get install python-virtualenv
Solution 5
python3 -m virtualenv virtualenv_name
or
python -m virtualenv virtualenv_name
Related videos on Youtube
Arial
Always inspired by products that solve meaningful problems.
Updated on July 16, 2022Comments
-
Arial almost 2 years
I couldn't get
virtualenv
to work despite various attempts. I installedvirtualenv
on MAC OS X using:pip install virtualenv
and have also added the
PATH
into my.bash_profile
. Every time I try to run thevirtualenv
command, it returns:-bash: virtualenv: command not found
Every time I run
pip install virtualenv
, it returns:Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
I understand that in mac, the
virtualenv
should be correctly installed in/usr/local/bin
The
virtualenv
is indeed installed in/usr/local/bin
, but whenever I try to run thevirtualenv
command, the command is not found. I've also tried to run thevirtualenv
command in the directory/usr/local/bin
, and it gives me the same result:-bash: virtualenv: command not found
These are the PATHs I added to my .bash_profile
export PATH=$PATH:/usr/local/bin export PATH=$PATH:/usr/local/bin/python export PATH=$PATH:/Library/Framework/Python.framework/Version/2.7/lib/site-packages
Any workarounds for this? Why is this the case?
-
Justin Fay almost 9 yearsTry adding a symlink to the virtualenv executable in /usr/local/bin
-
Arial almost 9 yearsWhere should I create the symlink? It's still not working despite I tried to add a symlink at the directory where I want to use virtualenv @justinfay
-
Justin Fay almost 9 yearsfrom looking at the paths above it could be something like, replace the last path in the command with the path to the actual virtualenv executable:
$ ln -s /usr/bin/virtualenv /Library/Framework/Python.framework/Version/2.7/lib/site-packages/virtualenv/virtualenv.py
-
Aliza over 8 yearswhat worked for me was to add a symlink
ln -s /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py /usr/local/bin/virtualenv
-
c24b over 8 yearsDoesn't work in a lubuntu
-
JulienD about 8 yearsWhat if you try
pip install virtualenv --user
? Also check the permissions of/usr/local/bin/
(you wrote that it was indeed installed in /usr/local/bin/, so if it is not found it looks more like a permissions issue). -
Ozkan Serttas about 4 yearsI tried adding Lazy Loading method to initialize virtualenv. Please see this part in the documentation
-
-
smudo78 almost 8 yearsI followed your solution and got the message "...If executing pip with sudo, you may want sudo's -H flag". Finally sudo -H pip install virtualenv did the job for me (on OS X), thank you
-
user5359531 almost 8 yearswhat if root is not available on your machine?
-
Mariano Kamp over 7 yearsDid you see that he was asking for Mac OSX?
-
Admin over 7 yearsSolved the problem. I guess this one can go into the global dir instead of
--user
. -
emrahgunduz over 6 yearson AWS EC2 instance with
Amazon Linux
, if you are trying Let's Encrypt'scertbot
, give this solution a try. This was the only suggestion that solved my virtualenv problem. -
Dmitri DB over 6 yearsWhich leaves the question: Why the devil is my python3-virtualenv package broken?
-
Kirby over 6 yearssetting up the sym link was all i needed to do. thank you.
-
race_carr about 6 yearsWow! This is what did the trick for me. I am using
pyenv
by the way -
TCSGrad almost 6 yearsThis is the way to go for Mac OS X using brew.
-
HellaDev about 5 yearsBeen fighting this for weeks and it has been hindering my limited time to work on a python project and this was the only solution to work for me on mac. Thank you!
-
CarmenA almost 5 yearsI upgraded to python 3.7. I kept trying to install virtualenv, it will always return "Error: Could not find a version that satisfies the requirement virtualenv (from versions: none)". I read somewhere that from a certain python 3.x version it comes with virtualenv installed, but trying to create a virtual environment simple, didn't work, it would return error that it doesn't know the virtualenv command. But it worked with the following command from your answer, "virtualenv venv --python=python3.7". Nothing else done prior. In case it helps anyone else. MacOS environment.
-
Leonard over 4 years
brew install python-virtualenv
does not exist -
Matteo over 4 yearsThe question is for mac OS, there is no
apt
-
David over 4 yearsThis worked perfectly. It should be the accepted answer and +1 for the detailed explanation
-
Ced over 4 yearsthe output is
sudo: /usr/bin/easy_install: command not found
-
Thomas Kimber over 4 yearsThankyou for this - but I wish I knew what witchcraft is at work here - what does "easy_install" do that regular pip doesn't do? i.e. Why does this work?
-
Nischaya Sharma over 4 yearsWorked like a charm on my 18.04, Thanks
-
manuele about 4 yearsIt fixes for me exacly the same problem... why it's not checked as the solution?
-
greybeard about 4 yearsVoted down to promote
apt
as a successor toapt-get
. -
yoon almost 4 yearsThis issue also happens when pip itself is installed in ~/.local/SOME_PATH. I
cp
ed everything insite-packages
dir into/usr/lib/pythonx.x/site-packages
, andrm -rf
ed the original directory. -
ofer.sheffer almost 4 yearsworked for me without the 3. python -m virtualenv <name>
-
Peter Wauyo over 3 yearsThis worked for me on MacOs
python -m venv venv_name
-
Jose Andres Montes Espinoza over 3 yearsAlso worked for Ubuntu. I was having issues setting it up for digital ocean. This should be the solution.
-
landesko about 3 yearsStep 4 was what I was looking for! I couldn't figure out how to get files out of ~/.local
-
DariusL about 3 yearsAlways a good method of solving path issues with python.
-
Hansang almost 3 yearsswitching to
sudo su
worked for me, even though i wanted to use python3 as the venv folder to be created. It seems that it's a permissions issue when trying to install locally and the elevated sudo not finding the correct path unless explicitly logged in as root -
ultrasounder over 2 yearsFollowed the above instructions and worked for me. @vettipayyan is not all that Vetti after all
-
Nathan McKaskle over 2 yearsThis only works most likely if python 3.6+ is the default when using the python command.
-
Nathan McKaskle over 2 yearsIt keeps trying to use 2.7.
-
Dushan Wijesinghe over 2 yearsWorks for macOS Big Sur 11.6
-
Nube Colectiva almost 2 yearsworked for me: "python -m virtualenv myvirtualenv" in windwos 10 - 64 bytes.