GNU/Linux ◆ xterm ◆ bash 1794 views

This terminal cast shows you how to install and create a virtualenv for python development using Ubuntu (actually LinuxMint) machine.

  1. Install virtualenv and virtualenvwrapper using pip or easy_install

  2. Find the location of virtualenvwrapper.sh shell script, copy the location.

  3. Open the .bashrc or .bash_profile or .profile based on your system.

  4. Append these two lines to the file

     export WORKON_HOME=$HOME/.virtualenv
     source <paste the location of the file>
  5. Save and close the file, run source .profile or .bashrc or .bash_profile

  6. As we are done with setting path for virtualenvwrapper, we are now going to create a virtualenv named ‘django’

     mkvirtualenv django
  7. The above command creates a virtual environment named django and installs the basic modules like distribute, argparse and wsgrief thus setting up a virtual python environment to work. You will automatically enter the virtualenv on successful creation.

  8. To come out of virtualenv

     deactivate
  9. To enter into a virtualenv

     workon django (or) name of the virtualenv you have created.
  10. To install a package inside virtualenv

    pip install packagename
    Eg: pip install Django
  11. If you already have requirement.txt file setup with your project

    pip install -r requirement.txt

This installs the modules freezed inside requirement.txt using pip freeze command

(Note: No need to use sudo inside virtualenv, just use pip install)