Wednesday 27 June 2012

How to install virtualenv, virtualenvwrapper in ubuntu

Follow below:

  • sudo apt-get update
  • sudo apt-get install python-setuptools python-dev build-essential git-core -y
  • sudo easy_install pip
  • sudo pip install virtualenv
  • sudo pip install virtualenvwrapper
  • mkdir ~/virtualenvs 
  •  echo "export WORKON_HOME=~/virtualenvs" >> ~/.bashrc
  •  echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc 
  •  echo "export PIP_VIRTUALENV_BASE=~/virtualenvs" >> ~/.bashrc 
  •  source ~/.bashrc 

  • mkvirtualenv blog

If you want to get out/off your virtualenv use this command:

  • deactivate

If you want to jump back on the virtualenv we just created and installed django use this command:

  • workon xxx
 
And finally if you want to remove the virtualenv altogether

  • rmvirtualenv blog 
     
     
     
      
Setup Eclipse: interpreter
Create a new PyDev Project

File -> New -> PyDev Project
A window will popup asking about the project details. Alternatively if you have already created a project go to
Project -> Properties
Click on "Click here to configure an interpreter no listed"
Click the New button
A new window will popup
Interpreter name: VIRTUALENVNAME (or whatever you like)
Interpreter executable: ~.virtualenvs/VIRTUALENVNAME/bin/python (or your custom location to the virtualenv/bin/python)

2 comments:

  1. This is the best mkvirtualenv tutorial, thank you!

    ReplyDelete
  2. Hi,

    Just a little comment: On ubuntu 14.04 the path for virtualenvwrapper.sh must be changed to

    "source /etc/bash_completion.d/virtualenvwrapper"

    ReplyDelete