0
0
Apache Airflowdevops~10 mins

Installing Airflow locally - Visual Walkthrough

Choose your learning style9 modes available
Process Flow - Installing Airflow locally
Start: Prepare environment
Create virtual environment
Activate virtual environment
Install Airflow with pip
Initialize Airflow database
Start Airflow webserver
Start Airflow scheduler
Access Airflow UI in browser
Done
This flow shows the step-by-step process to install and run Airflow locally using a virtual environment.
Execution Sample
Apache Airflow
python3 -m venv airflow_env
source airflow_env/bin/activate
pip install apache-airflow
airflow db init
airflow webserver -p 8080
airflow scheduler
Commands to create a virtual environment, install Airflow, initialize its database, and start the webserver and scheduler.
Process Table
StepCommandActionResult/Output
1python3 -m venv airflow_envCreate virtual environment folderFolder 'airflow_env' created with isolated Python environment
2source airflow_env/bin/activateActivate virtual environmentShell prompt changes, Python points to 'airflow_env'
3pip install apache-airflowInstall Airflow packageAirflow and dependencies installed in virtual environment
4airflow db initInitialize Airflow metadata databaseDatabase tables created, ready for Airflow use
5airflow webserver -p 8080Start Airflow webserver on port 8080Webserver running, logs show startup success
6airflow schedulerStart Airflow schedulerScheduler running, ready to execute workflows
7Access http://localhost:8080Open Airflow UI in browserAirflow dashboard loads, showing status and DAGs
8ExitStop commands or close terminalAirflow services stop, environment deactivated
💡 All steps completed successfully, Airflow is installed and running locally.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6Final
Virtual EnvironmentNoneCreated 'airflow_env'Activated 'airflow_env'Active 'airflow_env'Active 'airflow_env'Active 'airflow_env'Active 'airflow_env'Active 'airflow_env'
Airflow PackageNot installedNot installedInstalledInstalledInstalledInstalledInstalledInstalled
Airflow DBNot initializedNot initializedNot initializedInitializedInitializedInitializedInitializedInitialized
WebserverNot runningNot runningNot runningNot runningRunningRunningRunningRunning
SchedulerNot runningNot runningNot runningNot runningNot runningNot runningRunningRunning
Key Moments - 3 Insights
Why do we create and activate a virtual environment before installing Airflow?
Creating and activating a virtual environment isolates Airflow and its dependencies from other Python projects, preventing conflicts. This is shown in steps 1 and 2 of the execution_table.
What does 'airflow db init' do and why is it necessary?
'airflow db init' sets up the database tables Airflow needs to track workflows and tasks. Without this, Airflow cannot run properly. This is step 4 in the execution_table.
Why do we start both the webserver and the scheduler?
The webserver provides the user interface to monitor workflows, while the scheduler runs the workflows on time. Both are needed for Airflow to function fully, as seen in steps 5 and 6.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, after which step is the Airflow package installed?
AAfter step 2
BAfter step 3
CAfter step 4
DAfter step 5
💡 Hint
Check the 'Airflow Package' row in variable_tracker after step 3.
At which step does the Airflow webserver start running?
AStep 5
BStep 6
CStep 4
DStep 7
💡 Hint
Look at the 'Webserver' variable in variable_tracker and the execution_table step 5.
If you skip activating the virtual environment, what would likely happen when installing Airflow?
AThe installation fails with an error
BAirflow installs in the virtual environment anyway
CAirflow installs globally, possibly causing conflicts
DNothing happens, installation is skipped
💡 Hint
Refer to key_moments about virtual environment purpose and step 2 activation.
Concept Snapshot
Install Airflow locally:
1. Create virtual env: python3 -m venv airflow_env
2. Activate it: source airflow_env/bin/activate
3. Install Airflow: pip install apache-airflow
4. Initialize DB: airflow db init
5. Start webserver: airflow webserver -p 8080
6. Start scheduler: airflow scheduler
Use http://localhost:8080 to access UI.
Full Transcript
To install Airflow locally, first create a virtual environment to keep dependencies isolated. Activate it to use that environment. Then install Airflow using pip inside it. Initialize the Airflow database to prepare metadata storage. Start the Airflow webserver to access the UI and the scheduler to run workflows. Finally, open the browser at localhost port 8080 to see the Airflow dashboard. This process ensures Airflow runs cleanly on your machine without affecting other Python projects.