Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virtualenvwrapper commands aren't working

tow-81-235:Projects pessimisticoptimism$ mkvirtualenv development -bash: mkvirtualenv: command not found tow-81-235:Projects pessimisticoptimism$ sudo pip install virtualenvwrapper Password: Requirement already satisfied (use --upgrade to upgrade): virtualenvwrapper in /Library/Python/2.7/site-packages Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Python/2.7/site-packages (from virtualenvwrapper) Requirement already satisfied (use --upgrade to upgrade): virtualenv-clone in /Library/Python/2.7/site-packages (from virtualenvwrapper) Cleaning up... tow-81-235:Projects pessimisticoptimism$ mkvirtualenv development -bash: mkvirtualenv: command not found 

Why am I getting this error? I have virtualenv and virtualenvwrapper installed. I'd like to use mkvirtualenv and workon. I find it odd that virtualenv is working, but virtualenvwrapper isn't.

like image 880
Desolate Avatar asked Sep 02 '12 00:09

Desolate


People also ask

How does virtualenvwrapper work?

virtualenvwrapper is a set of extensions to Ian Bicking's virtualenv tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies.

What does virtualenvwrapper win do?

This is a port of Doug Hellmann's virtualenvwrapper to Windows batch scripts. The idea behind virtualenvwrapper is to ease usage of Ian Bicking's virtualenv, a tool for creating isolated Python virtual environments, each with their own libraries and site-packages.


2 Answers

1st, ensure you're installing with sudo:

sudo pip install virtualenvwrapper 

2nd, append the following lines to your .bashrc file (with nano ~/.bashrc):

export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh 

3rd, reload your profile

source ~/.bashrc 
like image 157
chirinosky Avatar answered Sep 21 '22 04:09

chirinosky


Summary

I'm on a Mac and my answer is similar to @Ramces answer except it was with bash_profile. I just want to elaborate a little further for Mac users to be aware that there's a lot of different profiles including:

  • .bashrc
  • .bash_profile
  • .profile

Some files like .profile do not take precedence over .bash_profile (if it exists) and will then be ignored. If you successfully do the below steps and get a virtual env working, but then close out your terminal and 'workon command not found', then you need to setup for the correct profile. For a detailed answer, see here

Install Steps:

  1. sudo pip install virtualenv

    Installs virtualenv (allows you to separate your envrionments)

  2. sudo pip install virtualenvwrapper

    Installs virtualenvwrapper (allows you to use the 'workon' command)

  3. nano ~/.bash_profile

    export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh 
  4. source ~/.bash_profile

    Reloads the profile. Going forward you only need step 5 (to create new environments) and step 6 (to run environments)

  5. mkvirtualenv my_env

    This creates your virtual environment (this example is with 'my_env')

  6. workon my_env

    This lets you work on a specific environment (this example is with 'my_env')

like image 31
Will Avatar answered Sep 21 '22 04:09

Will