Install Airflow on Windows with WSL

Page content

Hi, I am coder2j.

In this airflow tutorial, I will walk you through the steps to install Apache Airflow on Windows with WSL.

Let’s dive right in!

At the time of writing this post, the latest version of Apache Airflow is 2.6.3. On Windows, you can follow these steps:

Prerequisites #

Before you begin, make sure you have the following prerequisites:

  1. Windows 10 or later: WSL is only available on Windows 10 and later versions.
  2. Windows Subsystem for Linux (WSL): Ensure that you have WSL enabled on your Windows machine. If not, you can enable it by following Microsoft’s official documentation.
  3. A Linux Distribution: You’ll need a Linux distribution installed via WSL. Ubuntu is a popular choice and will be used in this guide.
  4. Python 3.7 or later: Make sure you have Python installed on your system. Airflow is compatible with Python 3.7 and above.

Step 1: Install WSL and a Linux Distribution #

  1. Open PowerShell as an administrator and run the following command to enable WSL:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Enable Windows Subsystem Linux feature via Powershell

  1. Visit the Microsoft Store and search for a Linux distribution (e.g., Ubuntu). Click “Install” to download and set up the distribution.

Download and install the Linux distribution Ubuntu from the Microsoft Store

  1. Once installed, launch the Linux distribution. You’ll be prompted to create a user and set a password. Follow the on-screen instructions to complete the setup.

Setup the username and password for the Ubuntu

If you hit the error of Error: 0x8007019e The Windows Subsystem for Linux has not been enabled. when launching the Ubuntu app, you need to reboot and it should solve.

Step 2: Install and Run Apache Airflow in WSL #

  1. Open your Linux distribution within WSL and create an Airflow project directory with the following command:
mkdir -p apps/airflow-local
cd apps/airflow-local/
  1. Make sure to have Python 3.7 or later installed and your Python virtual environment set up and activated.

terminal python virtual env activated in a project path

  1. Set the AIRFLOW_HOME environment variable to the current project directory:
export AIRFLOW_HOME=~/apps/airflow-local
  1. Install Apache Airflow using pip, we have Python 3.10 installed and want to install Airflow version 2.6.1:
AIRFLOW_VERSION=2.6.1
PYTHON_VERSION=3.10
CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"
pip install "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"
  1. After the installation is complete, run the airflow standalone command to initialize the database, create a user, and start all components:
airflow standalone

Your login username is admin and the password can be found in the standalone_admin_password.txt file in the project directory.

screenshot of airflow with admin login credentials

  1. You can now log in and access the Airflow web interface by opening a web browser and navigating to http://localhost:8080/.

screenshot of airflow running locally on Windows

That’s it! You should have successfully installed Apache Airflow on Windows with WSL.

Now, it’s your turn. Do I cover everything you need to get Airflow running?

Let me know if you face any issues or any suggestions in the comment below.

Related Posts