How to Install Flask in Python
A simple framework for building complex web applications.
pip install Flask
What is Flask?
A simple framework for building complex web applications.
Flask is a lightweight [WSGI] web application framework. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. It began as a simple wrapper around [Werkzeug] and [Jinja], and has become one of the most popular Python web application frameworks.
Flask offers suggestions, but doesn't enforce any dependencies or project layout. It is up to the developer to choose the tools and libraries they want to use. There are many extensions provided by the community that make adding new functionality easy.
The Pallets organization develops and supports Flask and the libraries it uses. In order to grow the community of contributors and users, and allow the maintainers to devote more time to the projects, [please donate today].
Quick Start
Minimal example to get started with Flask:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return "Hello, World!"
if __name__ == "__main__":
app.run(debug=True) # http://localhost:5000
Installation
pip (standard)
pip install Flask
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install Flask
pip3
pip3 install Flask
conda
conda install -c conda-forge Flask
Poetry
poetry add Flask
Dependencies
Installing Flask will also install these packages:
Verify the Installation
After installing, confirm the package is available:
python -c "import flask; print(flask.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing Flask with pip.
ModuleNotFoundError: No module named 'flask'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install Flask. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'flask' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install Flask to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'flask'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show Flask and upgrade with pip install --upgrade Flask.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install Flask. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user Flask
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org Flask
ConnectionError: Failed to establish a new connection
Cause: Server unreachable, URL invalid, or firewall/proxy blocking the connection.
Fix: Verify the URL and network access. Set HTTP_PROXY / HTTPS_PROXY env vars if behind a proxy.
SSLError: CERTIFICATE_VERIFY_FAILED
Cause: The remote server's SSL certificate cannot be verified.
Fix: Update CA certificates on your system. For testing only, disable SSL verification (never in production).
Runtime Errors
Common errors when using Flask after installation.
werkzeug.exceptions.NotFound (404)
Cause: The requested route is not registered.
Fix: Check route definitions with app.url_map. Verify the HTTP method (GET vs POST) matches.
RuntimeError: Working outside of application context
Cause: Flask globals (g, request, current_app) accessed outside a request context.
Fix: Wrap code with with app.app_context():
OSError: [Errno 98] Address already in use
Cause: Port 5000 is occupied by another process.
Fix: Use a different port: app.run(port=5001), or find and kill the occupying process.
Recent Releases
| Version | Released |
|---|---|
3.1.3 latest |
2026-02-19 |
3.1.2 |
2025-08-19 |
3.1.1 |
2025-05-13 |
3.1.0 |
2024-11-13 |
3.0.3 |
2024-04-07 |
Manage Flask
Upgrade to latest version
pip install --upgrade Flask
Install a specific version
pip install Flask==3.1.3
Uninstall
pip uninstall Flask
Check what is installed
pip show Flask