airflow: Error: ModuleNotFoundError: No module named 'airflow' | Docker Image Windows WSL2

Apache Airflow version: 2.0.0

Kubernetes version (if you are using kubernetes) (use kubectl version): NA

Environment: Local Windows Laptop

  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release): Windows 10 (WSL 2)
  • Install tools: Docker desktop in Windows 10 (WSL2)
  • Others:

What happened:

I am trying to setup local development with Airflow and was using the Docker-compose.yaml file in the repo. I am encountering the below error when I issues the command ‘docker-compose up airflow-init’

Starting airflowdocker_redis_1 … done Starting airflowdocker_postgres_1 … done Starting airflowdocker_airflow-init_1 … done Attaching to airflowdocker_airflow-init_1 airflow-init_1 | DB_BACKEND=postgresql+psycopg2 airflow-init_1 | DB_HOST=postgres airflow-init_1 | DB_PORT=5432 airflow-init_1 | airflow-init_1 | Traceback (most recent call last): airflow-init_1 | File “/home/airflow/.local/bin/airflow”, line 5, in airflow-init_1 | from airflow.main import main airflow-init_1 | ModuleNotFoundError: No module named ‘airflow’ airflowdocker_airflow-init_1 exited with code 1

What you expected to happen: I expected the containers to start and login to airflow via localhost:8080

How to reproduce it: Get the docker-compose.yaml from the repo. and then just follow the instructions on a windows machine.

Anything else we need to know: This occurs everytime

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I had this problem yesterday - it was down to the user config. It was fixed by setting in docker-compose:

user: "${AIRFLOW_UID:-1000}:${AIRFLOW_GID:-0}"

Yes i noticed that and accommodated that change. Would like you review it and probably test in another machine. Please let me know.

The airflow init through /bin/bash did not work for me. I had tweak that

@turbaszek Windows is not yet supported and this file has not been tested in any way on this system. Unfortunately docker-compose for Windows is very limited and buggy. Other projects provide virtual machine images as the recommended method for using their projects on Windows.

For example, Superset:

Windows

Superset is not officially supported on Windows unfortunately. The best option for Windows users to try out Superset locally is to install an Ubuntu Desktop VM via VirtualBox and proceed with the Docker on Linux instructions inside of that VM. We recommend assigning at least 8GB of RAM to the virtual machine as well as provisioning a hard drive of at least 40GB, so that there will be enough space for both the OS and all of the required dependencies.

https://superset.apache.org/docs/installation/installing-superset-using-docker-compose

We should probably describe what Windows support looks like and prepare workarounds. We even have a ticket about it: https://github.com/apache/airflow/issues/13838

I recently bought a few computers with Windows and when time permits I will experiment with it a bit.