Flask Install
# Flask Installation
# Flask Installation
Before we start writing Flask applications, we need to prepare the Python environment and install Flask.
Flask installation is relatively simple.
Flask is a Python library, so first make sure you have Python installed on your computer.
* * *
## Python Version Requirements
Flask 3.x requires Python 3.9 or higher.
If you haven't installed Python yet, you can download and install it from [python.org](https://www.python.org/downloads/).
After installation, open the terminal to verify:
$ python3 --version
Python 3.12.3
$ pip3 --version
pip 24.0 from /usr/lib/python3.12/site-packages/pip (python 3.12)
> macOS and most Linux distributions come with Python 3 pre-installed. If you're using Windows, make sure to check the Add Python to PATH option during installation.
* * *
## Virtual Environment
A Virtual Environment is a standard practice for Python projects, creating an independent Python package space for each project.
### Why Use Virtual Environment
Suppose you have two projects: Project A requires Flask 3.0, and Project B requires Flask 2.3.
If installed globally, the two Flask versions would conflict with each other.
Virtual environments give each project its own independent dependencies, preventing interference.
Python's built-in venv module can create virtual environments without needing additional tools.
### Create a Virtual Environment
First create the project directory, then create the virtual environment within it:
$ mkdir tutorial-flask-
YouTip