How to Install Flask: A Complete Setup Guide for Python Web Development
Flask is one of the most popular micro web frameworks for Python — lightweight, flexible, and beginner-friendly enough to get a simple web app running in minutes. Whether you're building a personal project, an API backend, or learning web development fundamentals, installing Flask correctly from the start saves a lot of frustration later.
What Is Flask and Why Does Installation Matter?
Flask is a WSGI (Web Server Gateway Interface) framework written in Python. Unlike heavier frameworks like Django, Flask gives you the bare essentials and lets you add components as needed. That simplicity is a feature — but it also means the installation environment you create directly affects how stable and portable your project will be.
Installing Flask isn't just running one command. It involves setting up the right Python version, creating an isolated virtual environment, and managing dependencies properly. Skip those steps and you risk version conflicts, broken projects, or a development setup that works on your machine but nowhere else.
Prerequisites Before You Install Flask
Before running any install command, confirm you have two things in place:
Python 3.7 or higher — Flask dropped support for Python 2 and older Python 3 versions. Run python --version or python3 --version in your terminal to check. If you're on an older version, update Python first through the official Python website.
pip — Python's package installer, which comes bundled with Python 3.4+. Confirm it's available with pip --version or pip3 --version.
| Check | Command | Expected Output |
|---|---|---|
| Python version | python3 --version | Python 3.7 or higher |
| pip availability | pip3 --version | pip version + location |
Step 1: Create a Virtual Environment 🛠️
This is the step beginners most often skip — and later regret. A virtual environment is an isolated Python installation scoped to a single project. It keeps Flask and its dependencies separate from your system Python and from other projects.
On macOS/Linux: