Now let's see how to install flask.
I'm going to start by creating a project directory for this application.
The directory is going to be called microblog.
And once I have the directory I can make it my current directory.
These two commands that I used on my terminal M-K there and CD are available on all operating systems.
So these will work on Unix Mac and Windows.
Now I need to install flask and for that I'm going to first create a virtual environment which our environments
are a nice feature of Python that allows you to create a private copy of the Python interpreter where
you can install your dependencies.
The benefit of using a vulture environment for your project is that in this way you can have multiple
projects on your system and each will have its own private copy of Python with their own dependencies.
So I'm going to go ahead and create a virtual environment.
Now this is done by invoking the Python interpreter as follows.
This invokes the interpreter and asks that a package that comes with it called The End is executed.
This is the package that deals with the creation of richer environments.
It comes with Python 3 the second VM in my command is the name that I'm going to give to this venture
environment.
Recall that if you're buying type or it's called by phone without the three that is what you need to
use for this command.
So I'm going to go ahead and render command.
And this created my router environment.
If I now get a directory listing I see that I have a VM subdirectory where a copy of Python is stored
next.
I need to tell my terminal session that I want to use the python that is in our environment instead
of the system wide one.
And the easiest way to do that is to activate the vector environment the command to activate the return
environment is as follows.
This works on Unix on Mac and it's selling the shell to import this activation script that was created
by the virtual environment.
As soon as I run the activation my prompt is modified to indicate that there is a better environment
that is activated.
If you are using the native Windows version of Python the activation command is slightly different.
On Windows you will have to do the following.
So you will type this command and you will achieve the same result and also your prompt will be modified
in the same way.
Now that I have an activated return varment I can go ahead and install flask for this.
I'm going to use the Python package installer which is called Pip Pip also exists in this rich environment
that I created so I can invoke it.
And run install flask.
This is going to bring a flask from the Python package repository along with a number of other packages
that flask depends on.
We call them the dependencies of flask to make sure that this installation is fully functional.
I can now start the Python interpreter one more time.
And since now I have a activated richer environment I don't need to say Python 3.
If that was the name of the system why Python now the naming is uniform so I can invoke the interpreter
as Python and that will also work.
So from here I can test that.
I have a flask correctly installed by importing flasks or import flask will bring the flask package
into this Python session and the expected result here is that you get no errors.
This means that the flask package was imported and now it's available for you to use.
For now we are not going to do anything else in this Python session so I'm going to go ahead and exit.
And now we are ready to write our first flask application.