Making Your Own World in The Real World Using Virtualenv

Handry Wahyudi
Aug 27, 2017 · 2 min read

Create virtual environment for wrapping the project

Virtual reality, virtual machine, virtual service, virtual friend even to the virtual wife… oh god save me from this world ☺.

But we will not talk about above virtual, it is to big. We will only talk about smaller than that i.e Virtual Environment or virtualenv.

A virtual environment is a tool that can keep module differences on different projects in one machine. confused? Yes, me too.wkwkwkkw

For example I’m working on two projects in one machine, project A using Flask 0.12.2 module while project B using a lower version of Flask 0.9.1. Viewed from the version that they used is very far and of course there will be many differences between the two. Well, to solve this problem in order the two modules are not interfere with each other and can be used simultaneously in one machine, we must make virtualenv.

The first step is to install virtualenv via pip, you can see how to use pip here.
Test your instalation.

$ virtualenv --version 15.1.0

In this case i have two folders ‘projectA’ and ‘projectB’, Inside every folder there is ‘env’ folder. Well, this ‘env’ folder that we will use as a virtual environment that contains python interpreter and it’s supporting module.

To create virtualenv folder:

$ virtualenv projectA/env $ virtualenv projectB/env

To enable virtualenv just use the command:

$ source projectA/env/bin/activate

If you success to do it, you will see the terminal will change to like below. This indicates that you already in a virtual environment and ready to work on the project.☺

(env) handry@sangmadesu:~/Desktop$

Yeeeahh you just use pip commands on it…:D

Thanks.


Originally published at www.zzzpython.com on August 27, 2017.

)

Handry Wahyudi

Written by

PunkShitBackSo | Cloud Enthusiast | Bad Code Maker.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade