Using Virtualenv

It is a good practice to use virtualenv to setup independent pythoon envirnoment. Especially, there are multi-version of python this machine.
For details check here

Install

Using Pip (>1.3) install

$ [sudo] pip install virtualenv

Using

  1. Create a folder for this env (trying to setup a python2.7 env)
    $ mkdir py27env
    $ cd py27env
  2. Create virtualenv for python2.7, in my mac the python27 is located at /usr/bin/python2.7
    thus a virtualenv is created with then name (folder) py27env by python2.7
    $ virtualenv --python=/usr/bin/python2.7 py27env
  3. Active the env
    $ cd py27env
    $ source bin/activate
    Then you can see the shell prompt is changed, py27env is added to the shell prompt
    (py27env) C02NF73EG3QD:py27env guyu$
  4. Leave the env
    Run the following script under the env
    $ deactivate
    if you want to clean all the env, then you can remove the folder
    $ rm -r path/to/env