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.
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.
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.
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
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:
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:
sudo pip install virtualenv
Installs virtualenv (allows you to separate your envrionments)
sudo pip install virtualenvwrapper
Installs virtualenvwrapper (allows you to use the 'workon' command)
nano ~/.bash_profile
export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh
source ~/.bash_profile
Reloads the profile. Going forward you only need step 5 (to create new environments) and step 6 (to run environments)
mkvirtualenv my_env
This creates your virtual environment (this example is with 'my_env')
workon my_env
This lets you work on a specific environment (this example is with 'my_env')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With