How to install django is the first question in mind whenever someone wants to start learning it. So in order to use it for making project or just learning django, you need to install it first. Let’s discuss how we can install django?
What is Virtual Environment?
Virtual environment is basically a way to keeping your different project directories separate to overcome the load on computer. As your projects expand you need to install different dependencies about different packages and this where virtual environment comes into play. Virtual environment keeps your all projects dependencies on separate place, so that you can refer to that later on.
Why we use Virtual Environment For Django?
As i mentioned above in our projects we might need a lot of libraries to install for some particular functionalities, So virtual environment comes handy in these situations. It also helps our system not getting over load by creating separate project dependencies.
Install Virtual Environment
To install django, the first thing you need to do is to install virtualenv into your pc.
So head over to command prompt and type the following command.
pip install virtualenv
Sometimes the above command gives error in windows PC as if someone open it without administrative previleges. So you need to open command prompt by right clicking on it and select run as administrator. And this command will work just fine.
Now that you have install virtualenv into your PC, now it is time to create a virtual environment and install django inside that environment.
To create a virtual environment, create a folder and name it whatever you want. I will name it as development for now and place it on desktop.
Open up Command Prompt and navigate to the folder you’ve just created.
Create Virtual Environment
Once you go into that folder, type the following command to create a virtual environment.
By typing the above command you will see something like this.
so now we have created a virtual environment and named it as env.
It is time to activate the virtual environment and install django.
You will see something like this.
Once you type the above command and hit enter then you will see your environment name placed inside brackets and this means that our environment is activated successfully.
Now let’s install django inside our virtual environment so that we can use to create our project and start working on it.
Once your virtual environment is activated, then you can install django by just typing the following command inside command prompt.
pip install django
This will install django for you. To check that you django is installed successfully, type the following command in command prompt and you will see some packages installed.
Check If django is installed or Not?
You will see some packages installed. If you want to start a django project right now click here.
So Now django is successfully installed. Want to learn more about how to learn web development click here. Happy Coding!