Installing Airflow locally on Windows with WSL and Astro CLI (quickest setup ever)
This guide uses the Astro CLI to install Airflow quickly. This is roughly based on the guide provided by Astronomer — but in my case, since I am running Windows 10.0, I was never able to get the mounting to work. I also suspect the guide is slightly outdated.
So I’m sharing my personal experience of how I got it installed and working.
Install WSL
WSL stands for Windows Subsystem for Linux, which allows us to run Linux on Windows very simply, removing the need of dual-booting or setting up a virutal machine.
First, make sure you have installed WSL. If not, follow this doc from Microsoft.
- The tl;dr is open Powershell in Windows while right-clicking on it and selecting “Run as administrator”.
- Run this:
- Restart your computer.
- Open your newly installed Ubuntu by going to Start Menu → Ubuntu
- Enter a username and password for yourself
- Run this:
- Confirm that Python is installed with
python3 --version
- Install pip:
sudo apt update
,sudo apt install python3-pip
- Run
pip3 --version
to confirm successful installation.
Install Docker Desktop on Windows
- Now go back to Windows. Download and install Docker Desktop
- Ensure the Use WSL 2 instead of Hyper-V option on the Configuration page is selected
- Open Docker Desktop
- Go to Settings -> Resources -> WSL Integration
- Make sure you have Ubuntu turned on
Install VS Code on Windows
I’m not sure if this would work with any other IDE, but VS Code has this native integration with WSL2 that makes it super easy to develop with.
So make sure you have Visual Studio Code installed on your Windows
Install Airflow on Ubuntu
- Now open your Ubuntu terminal again.
- Run
pip3 install apache-airflow
- Run
nano ~/.bashrc
- Add line
export AIRFLOW_HOME=/home/wynnelo/AirflowHome
(obviously replacingwynnelo
with your own username) cd /home/wynnelo
andmkdir AirflowHome
Install Astro CLI on Ubuntu
- In your Ubuntu terminal, type in
curl -sSL https://install.astronomer.io | sudo bash
- Run
astro --version
to verify successful installation cd /home/wynnelo/AirflowHome
- Now initialize your Astro project:
astro dev init — use-astronomer-certified
- Then
astro dev start
to start your local Airflow - Navigate to
http://localhost:8080/
and you should see your local Airflow set up and running!
How to edit the code?
- All you have to do is
cd /home/wynnelo/AirflowHome
on your Ubuntu terminal - Then type
code .
which should launch Visual Studio Code on your current directory on Ubuntu! - You can then proceed to edit code as usual and save as usual.