Thumbnail article
Install virtualenv on linux using virtualenvwrapper

An easy way to use virtualenv is by using the virtualenvwrapper. By using virtualenvwrapper you can easily switching to another environment by using workon command. In this article we will tell you how to install virtualenvwrapper in linux. First make sure you already install python, and then check is your pip already install using this command

pip -V

If pip is not found you can run both of command below, but if already install you just need run the install virtualenvwrapper command

sudo apt-get install python-pip 
sudo pip install virtualenvwrapper

And then create a dir store on home and export the folder using these command.

mkdir ~/.virtualenvs
export WORKON_HOME=~/.virtualenvs

Add this line to the end of ~/.bashrc so that the virtualenvwrapper commands are loaded.

. /usr/local/bin/

Exit the terminal and reopen it.  And hoalaa the virtualenvwrapper is ready to use. This is the commands for virtualenvwrapper.

mkvirtualenv [virtualenvname]
Create a new virtualenv environment named . The environment will be created in WORKON_HOME.

workon [virtualenvname]
Run this command to activate or change the environment.

List all of the enviornments stored in WORKON_HOME.

rmvirtualenv [virtualenvname]
Remove the environment . Uses folder_delete.bat.

Deactivate the working virtualenv and switch back to the default system Python.

Virtualenv is a tool for creating isolated virtual python environments. Isolated means closed and inaccessible from the outside. Python programs that running inside a virtualenv have their own modules and programs from outside cannot access them. Python programs that run without virtualenv can only use global modules. Virtualenv will become the best option when we work on several applications/projects with the same module but require different versions. For example when we develop a web application with flask version 0.1.x and then we develop another application with flask 1.2.x then virtualenv can isolate our work. If from the example we don’t create a virtualenv then the flask 0.1.x (first) application/project will become flask 1.2.x and all the modules we need will to be updated every time we use pip. After installing the package you can creating the virtualenv by running the command below.

mkvirtualenv [virtualenvname]

If you want to deactivate the virtualenv you can run


If you want to activate activate again the virtualenv that has been created you can run

workon [virtualenvname]

You can install a python package inside the virtualenv while the virtualenv active.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *