Thursday, 12 May 2016

How to setup virtualenv for python on ubuntu

Run following commands:


   change to python 3
  $ sudo ln -s /usr/bin/python3.5 /usr/bin/python
   $ sudo apt install python3-pip

   $ sudo apt-get install python-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 myenv


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 myenv



And finally if you want to remove the virtualenv altogether

$ rmvirtualenv myenv

No comments:

Post a Comment