Setting Up Django Environment Setup
May 3rd 2020 476

Before we install Django we will get you to install an extremely useful tool to help keep your coding environment tidy on your computer. It's possible to skip this step, but it's highly recommended. Starting with the best possible setup will save you a lot of trouble in the future!
Setting Up Django Environment Setup
Set up virtualenv
So, let's create a virtual environment (also called a virtualenv). Virtualenv will isolate your Python/Django setup on a per project basis. This means that any changes you make to one website won't affect any others you're also developing. Neat, Right?
All you need to do is find a directory in which you want to create the virtualenv ; your home directory, for example. On Windows, it might look like C:\Users\Name\ (where Name is the name of your login).
NOTE: On Windows, make sure that this directory does not contain accented or special characters; if your username contains accented characters, use a different directory, for example, C:\teachmebro .
For this tutorial we will be using a new directory teachmebro from your home directory:
$ mkdir teachmebro
$ cd teachmebro
We will make a virtualenv called myvenv . The general command will be in the format:
$ python3 -m venv myvenv
Virtual environment: Windows
To create a new virtualenv , you need to open the command prompt and run python -m venv myvenv . It will look like this:
C:\Users\Name\teachmebro> python -m venv myvenv
Where myvenv is the name of your virtualenv . You can use any other name, but stick to lowercase and use no spaces, accents or special characters. It is also good idea to keep the name short – you'll be referencing it a lot!
Working with virtualenv: Windows
Start your virtual environment by running:
C:\Users\Name\teachmebro> myvenv\Scripts\activate
Virtual environment: Linux and OS X
We can create a virtualenv on both Linux and OS X by running python3 -m venv myvenv . It will look like this:
$ python3 -m venv myvenv
myvenv is the name of your virtualenv . You can use any other name, but stick to lowercase and use no spaces. It is also a good idea to keep the name short as you'll be referencing it a lot!
Working with virtualenv: Linux and OS X
Start your virtual environment by running:
$ source myvenv/bin/activate
Remember to replace myvenv with your chosen virtualenv name!
NOTE: sometimes source might not be available. In those cases try doing this instead:
$ . myvenv/bin/activate
You will know that you have virtualenv started when you see that the prompt in your console is prefixed with (myvenv) . When working within a virtual environment, python will automatically refer to the correct version so you can use python instead of python3 .
OK, we have all important dependencies in place. We can finally install Django!