1

I want to create a virtualenv but it doesn't find the command.

$ virtualenv venv
-bash: virtualenv: command not found

It is installed:

$ pip install virtualenv
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python2.7/site-packages
Cleaning up...

What could be causing that?

ustroetz
  • 291
  • 2
  • 7
  • 15

1 Answers1

3

If you want to use a command without typing the path to the executable, you need to put it (or a symbolic link to it) in one of the the directories where the system looks for executable whenever no path to the command is provided, for example /usr/bin and /usr/local/bin.

So in your case I would put a symbolic link to virtualenv in /usr/local/bin:

ln -s /path/to/virtualenv /usr/local/bin/virtualenv
cyphorious
  • 1,865
  • Thanks for your answer. Sorry I am quite new to all this. What shall I put into /path/to/virtualenv? – ustroetz Jul 14 '13 at 17:50
  • The path to the virtualenv executable. So since you've used pip to install virtualenv it SHOULD be /usr/local/lib/python2.7/site-packages/virtualenv.py – cyphorious Jul 14 '13 at 19:43
  • I tried that and it says File exists: $ ln -s /usr/local/lib/python2.7/site-packages/virtualenv.py /usr/local/bin/virtualenv ln: /usr/local/bin/virtualenv: File exists. If I try to make a new virtualenv it still doesn't work: $ virtualenv venv -bash: virtualenv: command not found – ustroetz Jul 14 '13 at 20:05
  • 1
    try ln -sf .... – cyphorious Jul 14 '13 at 20:06
  • $ ln -sf /usr/local/lib/python2.7/site-packages/virtualenv.py /usr/local/bin/virtualenv $ virtualenv venv -bash: /usr/local/bin/virtualenv: Permission denied $ sudo virtualenv venv Password: sudo: virtualenv: command not found – ustroetz Jul 14 '13 at 20:10
  • $ ls -al /usr/local/bin/ | grep virtualenv lrwxr-xr-x 1 myname admin 52 14 Jul 13:09 virtualenv -> /usr/local/lib/python2.7/site-packages/virtualenv.py -rwxr-xr-x 1 myname admin 445 13 Jul 19:12 virtualenv-clone -rwxr-xr-x 1 myname admin 34274 13 Jul 19:12 virtualenvwrapper.sh -rwxr-xr-x 1 myname admin 1388 13 Jul 19:12 virtualenvwrapper_lazy.sh – ustroetz Jul 14 '13 at 20:11
  • 1
    You need to run the command under superuser mode. so type sudo in front of the command: sudo ln -sf .... And read a bit about Mac OS X (or Unix/Linux) basics. – cyphorious Jul 14 '13 at 20:12
  • I did $ sudo virtualenv venv sudo: virtualenv: command not found – ustroetz Jul 14 '13 at 20:14