Installing Flask
Once your virtual environment is activated, install Flask:
pip install FlaskVerify installation
Section titled “Verify installation”You can quickly verify installation in Python:
python -c "import flask; print(flask.__version__)"What gets installed?
Section titled “What gets installed?”Flask depends on a few important libraries:
- Werkzeug: request/response handling, dev server
- Jinja2: templating engine
- ItsDangerous: signing cookies
- Click: CLI tooling
You don’t need to learn them all now, but it’s helpful to know what’s underneath.
Pinning versions
Section titled “Pinning versions”For learning projects, installing latest is fine.
For production apps, it’s common to pin versions in requirements.txt or use a tool like Poetry. (We’ll keep it simple in this tutorial track.)
What pip install flask actually brings
Section titled “What pip install flask actually brings”Flask is a small package that composes several others. Measured in a fresh virtual environment on CPython 3.14.4:
flowchart TD F["Flask 3.1.3"] --> W["Werkzeug
WSGI, routing, the dev server"] F --> J["Jinja2
the template engine"] F --> C["click
the flask CLI"] F --> I["itsdangerous
signs the session cookie"] F --> B["blinker
signals"] J --> M["MarkupSafe
HTML escaping"]
| measured in a clean venv | packages | site-packages |
|---|---|---|
pip install flask | 9 | 19 MB |
pip install django | 5 | 56 MB |
Worth pausing on, because it contradicts the usual shorthand. Django installs fewer packages than Flask — it is one large distribution, while Flask is a thin layer over several independent libraries. Flask is smaller on disk; it is not smaller by dependency count.
The nine are Flask, Werkzeug, Jinja2, MarkupSafe, click, blinker,
itsdangerous, colorama (Windows console colour) and pip itself.
See it move
Section titled “See it move”Check yourself
Section titled “Check yourself”-
Measured in clean virtual environments, pip install flask brought in 9 packages and django brought in 5. What does that tell you?
Flask was 19 MB against Django's 56 MB, so Flask is smaller on disk. But it is assembled from Werkzeug, Jinja2, click, itsdangerous and blinker, so it has MORE distributions, not fewer.
pch.quizShowAnswer
B — Flask is a thin layer composed of several independent packages, while Django is one large distribution — Flask was 19 MB against Django's 56 MB, so Flask is smaller on disk. But it is assembled from Werkzeug, Jinja2, click, itsdangerous and blinker, so it has MORE distributions, not fewer.
-
Why is Flask==3.1.3 in requirements.txt not enough to reproduce an install?
A new Werkzeug can alter routing or dev-server behaviour with Flask unchanged. Record every package with pip freeze or a lock file.
pch.quizShowAnswer
B — Flask's dependencies are separate projects that release independently, so Werkzeug or Jinja2 can change under a fixed Flask — A new Werkzeug can alter routing or dev-server behaviour with Flask unchanged. Record every package with pip freeze or a lock file.
pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading