Virtualenv is the ruby equialent of ruby’s rbm.
To start using Virtualenv, you need to run the following as the root user:
$ yum install python-pip $ pip install virtualenv $ pip install virtualenvwrapper # optional but provides the workon
From this point forward you can run all other commands as the normal user.
By convention, we create the following folder which will house all our virtual environments, then cd into it:
$ mkdir .virtualenvs $ cd .virtualenvs
Next we create the environment with the name ‘testenv’:
$ virtualenv testenv
This will create the folder in the cwd with the same name.
Next we activate our new python virtualenv environment which we do like this:
$ . /testenv/bin/activate
This will end up changing your command prompt to indicate you are running in an isolated environment. To confirm this, run:
$ which python
From this point forward, any ‘pip install’ commands you run will install inside our testenv folder.
to return to system level python, run:
Note, when writing python code, you should do it outside of the .virtualenv folder. .virtualenv folder is mainly for internal use.
To switch between environments, you do:
$ workon envname
Note: this needs extra config to get workon command working, including updating your .profile file