4) Flask Installation & Setup Lesson

Install Python and Setup a Virtual Environment for Flask

3 min to complete · By Brandon Gigous

For this course you will need Python 3.6 or higher. Check whether your system fulfills those requirements by typing the following into your terminal:

python3 --version

# or

python --version

# OUTPUT
Python 3.6.15

If you do have Python installed, it'll likely be a higher version that this, but as long as it's 3.6 or above, you'll be fine for this course.

Install Python

If you don't have a fitting Python version installed, please follow the instructions in our Python 101 course - How to Install Python, and work your way through that section to get set up. Make sure that you are able to enter the Python interpreter, and that the version is at least 3.6. Once that is complete, return here to continue with setting up your virtual environment.

Illustration of a lighthouse

Info: This course already assumes some familiarity with programming, so it won't go into detail regarding the installation process. If you have troubles with the setup, please reach out on Discord.

Create a Virtual Environment

Once you have Python installed, it's time to set up a virtual environment. It's important to keep the project's dependencies and libraries contained in a virtual environment, so that you can develop your first Flask app without worrying about those pesky library clashes. Throughout this course, you'll be using the venv python module to create virtual environments.

If you aren't already there, go ahead and change your directory to your flask-webdev project folder. It would look something like this if you followed the folder structure instructions up to this point:

$ cd ~/Documents/CodingNomads/projects/flask-webdev

Then in the command line use Python to create your virtual environment:

$ python3 -m venv env

The choice is yours in what to name your virtual environment folder. In this case, the name env is used. Now all you'll need to do is "activate" the virtual environment. In your command line, type:

$ source env/bin/activate

ACTIVATED!

With your environment activated, you should see (env) at the beginning of your terminal input. Remember, you'll want to activate your virtual environment every time you begin work on your project! All the dependencies and packages you'll need will be packed in the virtual environment as you continue developing.

Now for the moment you've been (very patiently) waiting for: installing Flask! Just one more click to the next lesson...

Morty Proxy This is a proxified and sanitized view of the page, visit original site.