Skip to content

Environment Setup

This chapter introduces how to prepare a development environment for Flask projects.

Prerequisites: Python 3.9+ already installed; recommended to use VS Code + Python extension.

Steps:

  1. Create project folder and enter it
  2. Create and activate virtual environment
  3. Install Flask
  4. Verify installation

Windows (PowerShell):

powershell
mkdir flask-demo; cd flask-demo
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install --upgrade pip
pip install "flask>=2.3"
python -c "import flask, sys; print('Flask', flask.__version__, sys.executable)"

macOS/Linux (bash/zsh):

bash
mkdir flask-demo && cd flask-demo
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install "flask>=2.3"
python -c "import flask, sys; print('Flask', flask.__version__, sys.executable)"

Optional Tools:

  • pip-tools/poetry/pdm: Dependency management
  • ruff/black/isort: Code quality
  • pre-commit: Commit hooks

Common Issues:

  • Windows activation script error: Run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned as administrator and retry
  • Multiple Python versions: Use py -3.11 -m venv .venv or explicitly use the Python path

Content is for learning and research only.