DEV Community

Chief
Chief

Posted on

Django virtual environment setup in 4 simple steps.

In this post, I will show you how to setup a django virtual environment in 4 simple steps.

Why you need to use a virtual environment.

First, let me start by explaining why it is important to setup a development environment for your django projects. The main reason why you need to setup a virtual environment for your django project is because one of your projects is likely to require a different version of an external library than another one. Hence, installing packages in same place means you can't work with different versions of the same library. In short, creating a virtual environment separates the dependencies of different projects by creating a separate isolated environment for each project.

4 steps to setup your django virtual environment.

  1. Create a folder where your project will recide.

mkdir portfolio

  1. Create virtual environment using python tool -virtualenv-.

virtualenv portfolioEnv

  1. Activate your virtual environment. Depending on where your activate script recides, you may need to use one of the following ways:

source portfolioEnv/Scripts/activate
or
source portfolioEnv/bin/activate

  1. Install django in your virtual environment. pip install django

That's it. You have created a virtual environment for your django project. Happy coding :)

Top comments (0)