Virtualenv Command Not Found

Arial picture Arial · Jun 30, 2015 · Viewed 279.1k times · Source

I couldn't get virtualenv to work despite various attempts. I installed virtualenv on MAC OS X using:

pip install virtualenv

and have also added the PATH into my .bash_profile. Every time I try to run the virtualenv 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 the virtualenv command, the command is not found. I've also tried to run the virtualenv 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?

Answer

Tal Avissar picture Tal Avissar · Jan 2, 2017

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.