Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash: mkvirtualenv: command not found

After following the instructions on Doug Hellman's virtualenvwrapper post, I still could not fire up a test environment.

[mpenning@tsunami ~]$ mkvirtualenv test -bash: mkvirtualenv: command not found [mpenning@tsunami ~]$ 

It should be noted that I'm using WORKON_HOME that is not in my $HOME. I tried looking for /usr/local/bin/virtualenvwrapper.sh as shown in the virtualenvwrapper installation docs, but it does not exist.

I'm running CentOS 6 and python 2.6.6, if this matters.


# File: ~/.bash_profile # ...  export WORKON_HOME="/opt/virtual_env/" source "/opt/virtual_env/bin/virtualenvwrapper_bashrc" 
like image 847
Mike Pennington Avatar asked Dec 13 '12 08:12

Mike Pennington


People also ask

Why Mkvirtualenv is not working?

Ensure you're logged in as root user or standard user with sudo privileges. Update the System package list. Then install Python build tools. Then install virtualenv and virtualenvwrapper packages.

What is Mkvirtualenv?

it's a linux command which is used to create virtual env. mkvirtualenv foo creates a new virtual env at your home directory. You may switch to that env by running workon foo on your linux terminal.

Where is virtualenvwrapper installed?

That installation installs virtualenvwrapper in the /usr/local/bin directory.


2 Answers

Solution 1:

For some reason, virtualenvwrapper.sh installed in /usr/bin/virtualenvwrapper.sh, instead of under /usr/local/bin.

The following in my .bash_profile works...

source "/usr/bin/virtualenvwrapper.sh" export WORKON_HOME="/opt/virtual_env/" 

My install seems to work fine without sourcing virtualenvwrapper_bashrc

Solution 2:

Alternatively as mentioned below, you could leverage the chance that virtualenvwrapper.sh is already in your shell's PATH and just issue a source `which virtualenvwrapper.sh`

like image 132
Mike Pennington Avatar answered Sep 22 '22 15:09

Mike Pennington


Try:

source `which virtualenvwrapper.sh` 

The backticks are command substitution - they take whatever the program prints out and put it in the expression. In this case "which" checks the $PATH to find virtualenvwrapper.sh and outputs the path to it. The script is then read by the shell via 'source'.

If you want this to happen every time you restart your shell, it's probably better to grab the output from the "which" command first, and then put the "source" line in your shell, something like this:

echo "source /path/to/virtualenvwrapper.sh" >> ~/.profile

^ This may differ slightly based on your shell. Also, be careful not to use the a single > as this will truncate your ~/.profile :-o

like image 45
Erich Avatar answered Sep 25 '22 15:09

Erich