How to install Virtual Env



I am new to C9, but looking closely at it as an option to move most of my projects from my MAC. I cannot find any documentation on exactly how virtual environments are setup and was hoping someone could enlighten me.

I setup virtual environments on my local machine as well as at and listed below are the terminal commands I am used to running to setup the two environments. They are nearly identical except for one is /usr/bin and the other is /usr/local/bin. And to launch my environment, I would simple start it with the command workon django_dev

mkvirtualenv --python=/usr/bin/python3.5 django_dev (Python Anywhere)
mkvirtualenv --python=/usr/local/bin/python3.5 django_dev (local)

Thank you for your help.



Can you post what you see when you run these commands in Cloud9?


Hi Brady

On both I get bash: mkvirtualenv: command not found

I’ve installed virtualenv with pip install virtualenv, which seems to have installed it in /usr/local/lib/python2.7/dist-packages , but still get the same response when running the commands.

Any ideas? Thank you.


Can you also try this in a brand spanking new Python workspace to see if you have the same issues? I know I’ve got virtualenv working in a Python workspace before so a clean one should do the trick for you. From there, you can work backwards and see what changes are breaking it on your current workspace.



Ok, so this is a perfect example of working in a particular dev environment for too long :slight_smile:

Two ways of doing it - (this is why I got turned around, because I was doing the later)
One Way
$ [sudo]pip install virtualenv
$ virtualenv --python=/usr/bin/python3 venv(or whatever name you want)
$ source venv/bin/activate
$ deactivate (to close your virtualenv)

Another Way(this is my normal flow) - Virtualwrapper sits on top of Virtualenv
$ [sudo]pip install virtualenvwrapper
Add Commands to Bash
$ export WORKON_HOME=$HOME/.virtualenvs
$ export PROJECT_HOME=$HOME/Devel
$ source /usr/local/bin/
Make VirtualEnv
$ mkvirtualenv --python=/usr/bin/python3 project_dev(or whatever you want to call it)
Setup Environmental Variables File(this is just a sample Django setup)
$ nano $VIRTUAL_ENV/bin/postactivate
add your variables then save/overwrite(just a sample of my typical environment file)
export DJANGO_SETTINGS_MODULE='app.settings.development' export SECRET_KEY='5r^ky@c1#jr2+!p_x=9rwisj*nxmktorpzssam-e!=#ut^dswu' export DATABASE_NAME='database_name' export DATABASE_USER='database_user' export DATABASE_PASSWORD='' export DATABASE_HOST='' export DATABASE_PORT=''
$ deactivate (once you set the variables, you need to deactivate to set them
$ workon project_dev (to activate your environment and load all your dependencies)

I hope this helps a few users out there - happy coding :slight_smile: