How to run Airflow on Windows
Solution 1:
Three Basic Options
I went through a few iterations of this problem and documented them as I went along. The three things I tried were:
- Install Airflow directly into Windows 10 - This attempt failed.
- Install Airflow into Windows 10 WSL with Ubuntu - This worked great. Note that WSL is Windows Subsystem for Linux, which you can get for free in the Windows store.
- Install Airflow into Windows 10 via Docker + Centos - This worked great as well.
Note that if you want to get it running as a Linux service, it is not possible for option number 2. It is possible for option number 3, but I didn't do it as it requires activating privileged containers in docker (which I wan't aware of when I started). Also, running a service in Docker is kind of against paradigm as each container should be a single process/unit of responsibility anyway.
Detailed Description of #2 - WSL Option
If you're gong for option 2, the basic steps are:
- Get WSL Ubuntu installed and opened up.
- Verify it comes with python 3.6.5 or so (
python3 -version
). - Assuming it still does, add these packages so that installing PIP will work.
sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
- Install pip with:
-
sudo apt-get install python-pip
(orpython3-pip
for Python 3)
-
- Run the following 2 commands to install airflow:
export SLUGIFY_USES_TEXT_UNIDECODE=yes
-
pip install apache-airflow
(orpip3
for Python 3)
- Open a new terminal (I was surprised, but this seemed to be required).
- Init the airflow DB:
airflow initdb
After this, you should be good to go! The blog has more detail on many of these steps and rough timelines for how long setting up WSL takes, etc - so if you have a hard time dive in there some more.
Solution 2:
I'm runnig airflow on windows 10 using docker.
1) First you need to install docker on your windows .
2) Run command docker version
from command prompt if you get output means docker installed succesfuuly
2) Then you need to pull airflow image using command docker pull puckel/docker-airflow
3) Next step is to run image docker run -d -p 8080:8080 puckel/docker-airflow webserver
4) This will run airflow and you can access webui at localhost:8080
5) To copy dags use this command docker cp sample_dag.py containerName:/usr/local/airflow/dags
To access airflow utility you need to access the bash shell of container . you can do so using docker exec -it containerName bash
.
Once you inside bash shell you can run command line utilities ex **airflow list_dags**
Hope it helps
Solution 3:
Instead of installing Airflow via pip, download the zip on the Airflow project's GitHub, unzip it and in its folder, run python setup.py install
on the command line. ERROR - 'module' object has no attribute 'SIGALRM'
errors will happen, but so far this had no impact on Airflow's functions.
Using this method, the airflow util will not be available as a command.
As a workaround, use the [current folder]\build\scripts-2.7\airflow
file, which is the python script for the airflow util.
Another solution is to append to the System PATH variable a link to a batch file that runs airflow (airflow.bat):
python C:\path\to\airflow %*
From this point, the tutorial may be followed normally:
airflow init
airflow webserver -p 8080
I have not tested how well or if Airflow's DAGs run on Windows.