0
0
FlaskHow-ToBeginner ยท 3 min read

How to Install Flask: Step-by-Step Guide for Beginners

To install Flask, open your terminal and run pip install flask. This command downloads and installs Flask and its dependencies so you can start building web apps.
๐Ÿ“

Syntax

The basic command to install Flask is simple and uses Python's package manager pip. Here is the syntax:

  • pip install flask: Installs the latest stable Flask version.
  • pip install flask==x.y.z: Installs a specific Flask version.
  • pip install --upgrade flask: Updates Flask to the latest version.
bash
pip install flask
๐Ÿ’ป

Example

This example shows how to install Flask and verify the installation by checking its version.

bash
pip install flask

python -c "import flask; print(flask.__version__)"
Output
2.3.2
โš ๏ธ

Common Pitfalls

Some common mistakes when installing Flask include:

  • Not using a virtual environment, which can cause package conflicts.
  • Running pip without the right Python version or permissions.
  • Typing flask with uppercase in the install command (it should be lowercase).

Always activate a virtual environment before installing Flask to keep your project dependencies clean.

bash
python -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate
pip install flask
๐Ÿ“Š

Quick Reference

Here is a quick summary to remember when installing Flask:

CommandPurpose
pip install flaskInstall latest Flask
pip install flask==x.y.zInstall specific Flask version
pip install --upgrade flaskUpdate Flask to latest
python -m venv venvCreate a virtual environment
source venv/bin/activateActivate virtual environment (Linux/macOS)
venv\Scripts\activateActivate virtual environment (Windows)
โœ…

Key Takeaways

Use pip install flask to install Flask quickly and easily.
Always use a virtual environment to avoid conflicts with other Python packages.
Check your Flask version with python -c "import flask; print(flask.__version__)" after installation.
Use lowercase flask in the install command to avoid errors.
Upgrade Flask anytime with pip install --upgrade flask to get the latest features.