python – How to start a Django project using virtualenv?

Question:

I've already searched and found several different ways and conventions for creating a project in Django using a virtual environment (virtualenv). Is there any standard for this? Does anyone help me with a correct walkthrough?

I use python 2.7 + Django 1.8

Answer:

Assuming that you already have pip installed, using the isolated environment approach is very simple, even more so with virtualenvwrapper. Virtualenvwrapper is, as the name implies, a wrapper for virtualenv, bringing commands that facilitate the use of its functions.

pip install virtualenvwrapper

If you haven't installed virtualenv before, the above command will do it for you.

After that, to create a new environment it is very simple:

mkvirtualenv nome_da_env

When finished, your env will be created, and if you have correctly configured the virtualenvwrapper (for the case of using a Unix-like OS), your env will already be activated. To disable it, just run the command:

deactivate

And to activate, or switch environments:

workon nome_da_env

In summary: install virtalenvwrapper, configure it as mentioned in the link above, and use these commands to make your life easier.

Scroll to Top