home
diamond Go Premium
Data Engineering Path  ·  Airflow
Apache Airflow Logo

Installing Airflow Locally

🚀 Setting Up Your Local Development Environment

There are several ways to install Airflow locally. The right choice depends on your experience level and what you want to accomplish.


Installation Methods Comparison

Method Complexity Best For Reproducible?
pip install 🟢 Low Quick learning, single-user dev No
Docker Compose 🟡 Medium Team development, realistic setup Yes
Astro CLI 🟢 Low Professional development Yes
Helm Chart 🔴 High Production on Kubernetes Yes

Method 1: pip install (Quickest Start)

# 1. Create a virtual environment
python -m venv airflow_venv
source airflow_venv/bin/activate  # On Windows: .\airflow_venv\Scripts\activate

# 2. Set the Airflow home directory
export AIRFLOW_HOME=~/airflow

# 3. Install Airflow with constraints (IMPORTANT!)
AIRFLOW_VERSION=2.10.0
PYTHON_VERSION="$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')"
CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"

pip install "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"

# 4. Initialize the database
airflow db migrate

# 5. Create an admin user
airflow users create \
    --username admin \
    --firstname Admin \
    --lastname User \
    --role Admin \
    --email admin@example.com \
    --password admin

# 6. Start Airflow (in separate terminals)
airflow webserver --port 8080    # Terminal 1
airflow scheduler                 # Terminal 2
🚨 Caution
Always use constraint files when installing Airflow. Airflow has hundreds of dependencies, and without constraints, you'll get incompatible library versions. The constraint URL ensures all dependencies are compatible with your Airflow version.

Method 2: Docker Compose (Recommended for Teams)

# 1. Create project directory
mkdir airflow-docker && cd airflow-docker

# 2. Download the official docker-compose.yaml
curl -LfO 'https://airflow.apache.org/docs/apache-airflow/2.10.0/docker-compose.yaml'

# 3. Create required directories
mkdir -p ./dags ./logs ./plugins ./config

# 4. Set the Airflow UID
echo -e "AIRFLOW_UID=$(id -u)" > .env

# 5. Initialize Airflow (first time only)
docker compose up airflow-init

# 6. Start all services
docker compose up -d

# 7. Access the UI
# Open http://localhost:8080
# Username: airflow
# Password: airflow

The official docker-compose.yaml includes:

Service Purpose
airflow-webserver Serves the UI on port 8080
airflow-scheduler Runs the scheduler daemon
airflow-worker CeleryExecutor worker
airflow-triggerer Handles deferrable tasks
postgres Metadata database
redis Celery message broker
flower Celery monitoring UI (port 5555)
💡 Tip
Docker Compose is the recommended method for local development because it closely mirrors a production deployment. Your DAGs go in the ./dags folder and are automatically synced to all containers.

Method 3: Astro CLI (Astronomer)

# 1. Install Astro CLI
curl -sSL install.astronomer.io | sudo bash

# 2. Initialize a new project
mkdir my-airflow-project && cd my-airflow-project
astro dev init

# 3. Start Airflow
astro dev start

# 4. Access the UI
# Open http://localhost:8080
# Username: admin
# Password: admin

The Astro CLI creates a clean project structure:

my-airflow-project/
├── dags/                    # Your DAG files
│   └── example_dag.py
├── include/                 # Supporting files
├── plugins/                 # Custom plugins
├── tests/                   # DAG tests
├── Dockerfile               # Custom Airflow image
├── packages.txt             # OS-level dependencies
├── requirements.txt         # Python dependencies
└── airflow_settings.yaml    # Connections & Variables

Post-Installation Verification

After installing Airflow using any method, verify your setup:

# Check Airflow version
airflow version

# Check database connection
airflow db check

# List example DAGs (should show default examples)
airflow dags list

# Test a specific DAG
airflow dags test example_bash_operator 2024-01-01
lock

This content is reserved for Premium Members.

Upgrade to Premium

Entity Details

Create New Item

help

Submit Technical Query

Have a question or run into an issue? Describe it below, upload an optional screenshot, and our engineering team will answer it!

image Attach image (optional)

Submit Feedback

build Free Developer Utility Free Tool
gavel

Privacy & Legal Disclaimer

1. Client-Side Browser Processing

All utility tools on DeepEngineerHub (including Image to PDF, Text Formatters, JSON Converters, and Encryptors) execute 100% locally within your client browser using WebAssembly and JavaScript. No uploaded images, text, or documents are transmitted, collected, or stored on remote servers.

2. Limitation of Liability ("As-Is" Provision)

Tools and services are provided free of charge for convenience and educational purposes "as-is" without warranties of any kind. DeepEngineerHub shall not be held liable for any data loss, formatting inconsistencies, or indirect damages resulting from tool usage.

3. Open Source & Third-Party Software

Certain utilities utilize open-source client libraries (such as jsPDF, Mermaid.js, Pyodide) licensed under MIT, Apache, or BSD open licenses. All intellectual property remains with their respective copyright holders.