Lesson 3 / 25
Installing and Running Locally
Install Airflow in a virtual environment with the official constraints and start it.
Use a venv and the constraints file
Airflow has many dependencies, so install it in a virtual environment with the project's constraints file for your Airflow and Python versions; that pins compatible versions and avoids dependency conflicts. For learning, airflow standalone initialises the database, creates an admin user and starts all components on one machine. For anything beyond learning, use Docker Compose, the official Helm chart or a managed service (Amazon MWAA, Google Cloud Composer, Astronomer). Set AIRFLOW_HOME to choose where config, logs and the DAGs folder live.
Install with constraints
Replace the version numbers with the release you want. Airflow 3.x requires a supported Python 3 version; check the install docs.
python3 -m venv af-venv && source af-venv/bin/activate
AIRFLOW_VERSION=3.0.6
PYTHON_VERSION="$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')"
pip install "apache-airflow==${AIRFLOW_VERSION}" \
--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"
export AIRFLOW_HOME=~/airflow
airflow standalone # learning only: DB + admin user + all componentsDo not use standalone in production
It uses a local SQLite database and a single process, which is fine for learning but not for concurrent, reliable production use.
Quick check: Why install Airflow with a constraints file?
- It is required to open the UI
- It makes Airflow free
- It removes the scheduler
- It pins compatible dependency versions and avoids conflicts
Answer
It pins compatible dependency versions and avoids conflicts — Constraints give a tested set of package versions for each release.