How to install airflow

May 25, 2025

Install airflow

Chosen version

airflow version: 3.0.1 python version: 3.11.12 docker installation: no

Installation

setup airflow home directory:

export  AIRFLOW_HOME=~/airflow

install airflow

pip  install  "apache-airflow[celery]==3.0.1"  --constraint  "https://raw.githubusercontent.com/apache/airflow/constraints-3.0.1/constraints-3.11.txt"

note: 3.11 means using python 3.11

initialise database:

airflow db migrate

get the initial password

cd ~/airflow
cat simple_auth_manager_passwords.json.generated

The output should look like:

{"admin": "Tqp8vGzhx434pnPV"}

Run airflow

airflow standalone

login at: https://localhost:8080/

Create a simple dag file

# ~/airflow/dags/simple_dag.py
from airflow import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime, timedelta

# Define a simple Python function
def greet():
    print("Hello from Airflow!")

# Default arguments for the DAG
default_args = {
    'owner': 'airflow',
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
}

# Define the DAG
with DAG(
    dag_id='simple_greet_dag',
    default_args=default_args,
    description='A simple DAG that greets',
    schedule='@daily',
    start_date=datetime(2024, 1, 1),
    catchup=False,
) as dag:

    # Define the task
    greet_task = PythonOperator(
        task_id='greet_task',
        python_callable=greet
    )

    greet_task