How to add virtualenv to path
Solution 1
It seems that I myself am the exception to the rule for almost all 'simple' installation procedures. For some reason, it WAS a path related issue:
I ran brew info python
, which outputted a lot of information. At the bottom I found this:
Executable python scripts will be put in:
/usr/local/share/python
so you may want to put "/usr/local/share/python" in your PATH, too.
I added that to my PATH in /etc/launchd.conf
and ~/.bashrc
and lo and behold:
$ which virtualenv
tells me:
"/usr/local/share/python/virtualenv"
I still don't know why I couldn't find any pointers in the right direction, online, anywhere? Is pip install virtualenv
supposed to add to the PATH itself? If so, why not on my system? Why did @bibhas tell me explicitly it was not a path issue?
Solution 2
Had the same issue after pip install virtualenv
When I inspected python ls -la /usr/local/bin/python
I found it was symbolically linked to /Library/Frameworks/Python.framework/Versions/2.7/bin/python
When I cd in that directory I also found the virtualenv executable and
Fixed it by
cd /Library/Frameworks/Python.framework/Versions/2.7/bin
ln virtualenv /usr/local/bin/virtualenv
Sidenote: I also happen to have a python installation in /System/Library/Frameworks/Python.framework/Versions/2.7/bin
I believe that's the one that came with OSX
Solution 3
In your .bashrc you need to have:
export WORKON_HOME=~/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
Solution 4
I solved it by:
At first, I found out it is located at /usr/local/python3
and then I fixed it by the command:
ln virtualenv /usr/local/bin/virtualenv
Solution 5
(Mac / Linux specific)
So I got an error message when I did a pip3 install --user --upgrade virtualenv
telling me that I did not have Users/home/Library/Python/3.7/bin
in my PATH. So I simply added it.
If this is on the Mac, the following did it for me
vi ~/.bash_profile
PATH="/Users/home/Library/Python/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
restart your terminal and type virtualenv env
and that should do it.
Related videos on Youtube
Comments
-
Michael Trouw over 2 years
I am trying to find out why my
virtualenv
and/orvirtualenv
wrapper - installed usingpip
usinghomebrew
- cannot be found. I think it's because it's not added to my PATH:$ which virtualenv $
and:
$ virtualenv someDir $ -bash: virtualenv: command not found
I installed pip using
homebrew
, andvirtualenv
usingpip
, without problems. I tried reinstallingvirtualenv
, but that did not work either. How do I know what path to add toPATH
? Just the path thatvirtualenv.py
seems to be installed into? That seems to be:/usr/local/lib/python2.7/site-packages/virtualenv.py
I also found this guide, which suggests this:
$ ln -s ../Cellar/python/2.7/Frameworks/Python.framework/Versions/2.7/bin/virtualenv virtualenv
However, it does not help me run
virtualenv
. I am on Mac OSX 10.7.5 (Lion).-
Bibhas Debnath about 11 yearsIt's not a path issue. Pip puts an executable file named
virtualenv
in/usr/local/bin/
when successfully installed. Trypip uninstall virtualenv
and then reinstallsudo pip install virtualenv
.sudo
because you'll need to install it in global scope. -
Michael Trouw about 11 years@Bibhas but if i load launchd.conf, i have /usr/local/bin added to my path so then i should be able to just use virtualenv in bash right? or pip only put it there when using sudo? where could i have found this information?
-
Michael Trouw about 11 years@Bibhas i tried what you suggested, i did: + $ pip uninstall virtualenv + $ pip uninstall virtualenvwrapper + $ sudo pip install virtualenv + $ cd /usr/local/bin/ + $ find virtualenv + find: virtualenv: No such file or directory`` So something is going wrong here? that would make sense... but why??
-
Bibhas Debnath about 11 yearshow did you install pip? which package did you install with brew? can you check the pip version with
pip -V
? when you install virtualenv with pip, does it give any error? can you post the install log? -
Michael Trouw about 11 yearsSee this screenshot d.pr/i/paQQ for the first 3 questions, and this one for installing virtualenv: d.pr/i/c4pE and virtualenvwrapper: d.pr/i/L7E0 Also, i had no errors installing virtualenv at any time, i did have warnings..
-
Scott Stensland almost 6 yearsmy solution was : sudo -H pip install virtualenv
-
-
Michael Trouw about 11 yearsi'm sorry, but my pip/bash fu is not nearly good enough to understand your solution, could you please elaborate?
-
Michael Trouw about 11 yearsWhen i try this (i've put it in both .bashrc which i had to create, and .bash_profile) it tells me this: -bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory
-
Michael Trouw about 11 yearsI think this is nice if it works out of the box, but 1) it's a workaround for my problem, and 2) i cannot install it using homebrew, which i came to like as a package manager since a few months :)
-
Michael Trouw about 11 yearsthis i could have expected: if i download pythonbrewm which relies on virtualenv, and i try to use it, guess what:
futuremaggel:~ supermaggel$ pythonbrew -bash: pythonbrew: command not found futuremaggel:~ supermaggel$ which pythonbrew futuremaggel:~ supermaggel$
it doesn't know the command or cannot find it.. same problem as i have with virtualenv. -
Claudiu almost 11 yearsfunny cause brew just told me to remove that from my path because it works differently now, yet then i could no longer use virtualenv..
-
aendra over 10 yearsThanks for a well-written solution, totally solved my problem.
-
northben over 10 yearsand then open a new bash shell:
bash
or close and reopen your terminal -
fearless_fool over 6 yearsWorked for me. I'm curious what caused it to end up in this state.
-
Kevin Smith over 3 yearsWorked for me, although my virtualenv executable was at a different location. Also turns out the pip install virtualenv, outcome, has a waring message indicating that /usr/local/bin/virtualenv should be added to PATH.