From the course: Flask Essential Training

Install Flask and Pipenv

From the course: Flask Essential Training

Start my 1-month free trial

Install Flask and Pipenv

- [Instructor] All right, let's go ahead and get started with our first Flask project. Now, before we get creating our Flask project, we've got to build a nice environment in which our project can live. So first let's go ahead and open up our terminal. Once we have that terminal open, we want to move to a place where we can work with our data. I'm going to do this on my Desktop, so I'm going to do a cd capital Desktop, and I'm going to move to my Desktop here, and then I'm going to create a virtual environment. Now, included with Python is the virtual environment package where you can create that. I really like the Pipenv package that allows you to both have a virtual environment and very easily manage the different packages that you're going to have for your project. So in order to make this, let's go ahead and first create a project directory where we can store all of our data. Now we are going to be creating that URL shortener, so let's go ahead and make a directory with mkdir space and then give a name for our project. I think we should use something like url-shortener. Now make sure that you don't have any spaces in the name of this folder, and go ahead and hit Enter there, and then we'll cd into that directory, cd url-shortener. Now that we're there, we're going to be using Pipenv in order to set up our environment. So let's go ahead and make sure that we have Pipenv installed on our computer. We're going to do pip3 install pipenv. Now, once that's finished we're going to go ahead and do a pipenv install and this is going to go ahead and get our directory up and running to be a Pipenv environment. So you'll see essentially what this entails, if I go ahead and do an ls here, it creates a Pipfile and a Pipfile.lock that essentially holds all the different packages that we're going to be working with here. Now what's great about Pipenv is that if we want to use our virtual environment and all the different packages that we have there, we can say pipenv shell, and then we are instantly launched into this virtual environment, right inside of that directory. And if we ever want to get out of this we can simply just type exit, and we're back to the regular version of our terminal here. But we are going to be using Pipenv here. So let's do our Pipenv shell to get back in there. And now it's time to install Flask. So let's go ahead, and type out pipenv install flask, and I want to make a special mention here that since we're using Pipenv, we don't install things via just Pip anymore, it's pipenv install, and then whatever package that you'd like. So let's go ahead and hit Enter on that. That's going to get Flask installed here. And once that's finished to confirm that this is working, let's go ahead and type out Flask and just hit Enter, and you should see a little pop-up like this. This tells you some of the basics of Flask. This will confirm that it's on your computer and ready to rock and roll.

Contents