Skip to content

Installing Flask

Once your virtual environment is activated, install Flask:

bash
pip install Flask

You can quickly verify installation in Python:

bash
python -c "import flask; print(flask.__version__)"

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.

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.)

Flask is a small package that composes several others. Measured in a fresh virtual environment on CPython 3.14.4:

diagram Diagram mermaid
measured in a clean venvpackagessite-packages
pip install flask919 MB
pip install django556 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.

sketch What one pip install pulls in p5.js
Flask is a thin layer over several independent packages, each with its own release schedule.
pch.quizTag pch.quizDefaultTitle
  1. Measured in clean virtual environments, pip install flask brought in 9 packages and django brought in 5. What does that tell you?

    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.

  2. Why is Flask==3.1.3 in requirements.txt not enough to reproduce an install?

    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.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading