WEBVTT
Kind: captions
Language: en

00:00:00.030 --> 00:00:04.110
In this section of the course we're
going to be creating our django

00:00:04.110 --> 00:00:09.599
application before we can create our
django app we need to create a Python

00:00:09.599 --> 00:00:14.309
virtual environment so we can install
all of the dependencies such as Python

00:00:14.309 --> 00:00:19.410
and the Django rest framework I'm going
to show you how to create a Python

00:00:19.410 --> 00:00:23.840
virtual environment on our vagrant
server

00:00:23.840 --> 00:00:26.070
load up the terminal and change

00:00:26.070 --> 00:00:33.980
to our project workspace courses and
then our profiles REST API project

00:00:33.980 --> 00:00:40.829
connect to the server by typing vagrant
SSH and then change directory to the

00:00:40.829 --> 00:00:44.780
forward slash vagrant directory

00:00:44.780 --> 00:00:47.610
you
create a Python virtual environment

00:00:47.610 --> 00:01:00.800
using Python 3 with the Python venv
command so if we do Python - m venv

00:01:00.800 --> 00:01:07.220
and then you set the path where you want
to create the virtual environment so the

00:01:07.229 --> 00:01:11.729
virtual environment is a set of files
which you work on and this is the

00:01:11.729 --> 00:01:16.470
directory where it installs all of the
dependencies when you install them with

00:01:16.470 --> 00:01:18.940
the Python package manager

00:01:18.940 --> 00:01:24.960
So we're going to create it in tilde (~) forward slash env

00:01:24.960 --> 00:01:31.040
what this does is it creates a new file
in our vagrant server home directory

00:01:31.040 --> 00:01:37.770
called env and creates our Python
environment there now the reason I do it

00:01:37.770 --> 00:01:42.450
here is because I don't want this
environment to synchronize with our

00:01:42.450 --> 00:01:47.280
local machine so if you ever need to
destroy and recreate the vagrant server

00:01:47.280 --> 00:01:52.960
from scratch you can do that with a
fresh Python virtual environment

00:01:52.960 --> 00:01:58.460
This is why I specify this tilde because it will
create the environment in the home

00:01:58.469 --> 00:02:03.930
directory of our vagrant server as
opposed to the vagrant folder which is

00:02:03.930 --> 00:02:07.380
synchronized to our local machine

00:02:07.380 --> 00:02:10.020
Ok so
once you've typed that hit enter and this

00:02:10.020 --> 00:02:13.140
will go ahead and create 
a new virtual environment for our

00:02:13.140 --> 00:02:15.500
project

00:02:15.500 --> 00:02:17.700
the way that virtual
environments work is you need to

00:02:17.700 --> 00:02:22.620
activate them and deactivate them so
when you're activated on a virtual

00:02:22.620 --> 00:02:26.909
environment all of the dependencies that
you run in the Python application will

00:02:26.909 --> 00:02:32.549
be pulled from the virtual environment
instead of the base operating system the

00:02:32.549 --> 00:02:38.819
way you activate a virtual environment
is you type source and then the path to

00:02:38.819 --> 00:02:43.470
the activate script within our
environment so in our case this path

00:02:43.470 --> 00:02:54.420
would be in the home directory or tilde
/env/bin forward slash activate then

00:02:54.420 --> 00:02:58.349
hit enter you know that you're working
on a virtual environment because the

00:02:58.349 --> 00:03:02.670
name of the virtual environment you're
working on appears in brackets at the

00:03:02.670 --> 00:03:07.060
prefix of the command line input

00:03:07.060 --> 00:03:09.450
the way
that you switch off a virtual

00:03:09.450 --> 00:03:16.440
environment is you just type deactivate
and then you can see that the name of

00:03:16.440 --> 00:03:21.329
the virtual environment disappears from
the prefix and you are now deactivated

00:03:21.329 --> 00:03:24.380
from that virtual environment

00:03:24.380 --> 00:03:26.879
I'm going
to provide a cheat sheet in the

00:03:26.879 --> 00:03:30.989
resources of this video which provides
all of these commands because I know

00:03:30.989 --> 00:03:34.700
that it can be a lot to remember when
you're doing this for the first time

00:03:34.700 --> 00:03:41.450
that's how you activate and deactivate a
virtual environment with Python

