# How to pip install Flask on Python 3: The Complete Guide

> Learn the recommended way to pip install Flask on Python 3 using a virtual environment. Avoid conflicts and install Flask correctly for your projects.

- Repository: [Pallets/flask](https://github.com/pallets/flask)
- Tags: tutorial
- Published: 2026-02-11

---

**Use `python3 -m pip install Flask` inside a virtual environment to install the framework into the correct Python interpreter while avoiding system-wide package conflicts.**

Flask, the lightweight WSGI web framework maintained by the pallets/flask repository, is distributed exclusively on PyPI and designed to install cleanly with standard Python packaging tools. Executing `pip install flask` correctly guarantees that the `Flask` class defined in [`src/flask/app.py`](https://github.com/pallets/flask/blob/main/src/flask/app.py) and the CLI utilities exposed through [`src/flask/cli.py`](https://github.com/pallets/flask/blob/main/src/flask/cli.py) are placed in your interpreter's site-packages directory without interfering with system packages.

## Use python3 -m pip to Install Flask

The recommended method is to invoke pip as a module using the specific Python interpreter you intend to use:

```bash
python3 -m pip install --upgrade pip
python3 -m pip install Flask

```

**Why `python3 -m pip`?** Running pip via `python3 -m` ensures you are using the pip installation associated with that specific interpreter, preventing scenarios where a system-wide `pip` executable installs packages into a different Python version. This approach guarantees that Flask's entry points—registered in [`src/flask/cli.py`](https://github.com/pallets/flask/blob/main/src/flask/cli.py)—are available to the correct Python binary.

According to the official guidance in `docs/installation.rst`, this module-based invocation is the safest cross-platform method to ensure packages land in the right environment when multiple Python versions exist on the system.

## Install Flask Inside a Virtual Environment

Isolation is critical for dependency management. Create a virtual environment before installing Flask to keep the framework and its dependencies separate from system packages:

```bash
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

python -m pip install Flask

```

**What happens during installation?** The command downloads the Flask distribution and installs the public API surface from [`src/flask/__init__.py`](https://github.com/pallets/flask/blob/main/src/flask/__init__.py), making the `Flask` class and helpers importable in your project. Because the environment is isolated, packages installed here do not affect the system-wide Python installation.

## Verify Your Flask Installation

Confirm that Flask installed correctly by checking the version and Python path:

```bash
python -c "import flask, sys; print(f'Flask {flask.__version__} installed on Python {sys.version.split()[0]}')"

```

This imports the package defined in [`src/flask/__init__.py`](https://github.com/pallets/flask/blob/main/src/flask/__init__.py) and outputs the version string, confirming that the `pip install flask` command placed the code in the active interpreter's site-packages directory.

## Pin to a Specific Flask Version

For reproducible builds, specify an exact version rather than accepting the latest release:

```bash
python -m pip install "Flask==2.3.3"

```

Lock this dependency in a [`requirements.txt`](https://github.com/pallets/flask/blob/main/requirements.txt) file:

```text
Flask==2.3.3

```

Then recreate the environment anywhere with:

```bash
python -m pip install -r requirements.txt

```

This ensures your production environment uses the same `Flask` class implementation from [`src/flask/app.py`](https://github.com/pallets/flask/blob/main/src/flask/app.py) that you developed against locally.

## Summary

- **Use `python3 -m pip`** to ensure Flask installs into the intended interpreter's site-packages and avoids conflicts with system-wide pip executables.
- **Always use virtual environments** (`python3 -m venv`) to isolate Flask and its dependencies from system packages, as recommended in `docs/installation.rst`.
- **Verify installations** by importing `flask` and checking `flask.__version__` to confirm the package from [`src/flask/__init__.py`](https://github.com/pallets/flask/blob/main/src/flask/__init__.py) is accessible.
- **Pin versions** with `Flask==x.y.z` in [`requirements.txt`](https://github.com/pallets/flask/blob/main/requirements.txt) for reproducible deployments across development and production machines.

## Frequently Asked Questions

### Should I use `pip` or `pip3` to install Flask on Python 3?

Use `python3 -m pip` instead of the `pip` or `pip3` executables. This guarantees that you are invoking the pip module associated with the specific Python 3 interpreter you intend to use, preventing installation into the wrong environment when multiple Python versions are present on your system.

### How do I check if Flask is installed correctly?

Run `python -c "import flask; print(flask.__version__)"` in your terminal. If this outputs a version number without an `ImportError`, the `Flask` class from [`src/flask/app.py`](https://github.com/pallets/flask/blob/main/src/flask/app.py) is available in your Python path and the installation succeeded.

### Can I install Flask without using a virtual environment?

While `python3 -m pip install Flask` will work against your global Python installation, it is not recommended. Installing into the system site-packages can break operating system tools that depend on specific package versions and creates conflicts between projects requiring different Flask releases.

### Where does pip install Flask after running the command?

pip places Flask's source files (including [`src/flask/app.py`](https://github.com/pallets/flask/blob/main/src/flask/app.py) and [`src/flask/cli.py`](https://github.com/pallets/flask/blob/main/src/flask/cli.py)) into the `site-packages` directory of the active Python interpreter—either your system Python or, preferably, the virtual environment's isolated library path. You can locate the exact directory by running `python -c "import flask; print(flask.__file__)"`.