skip to Main Content

I am developing and testing with airflow inside a docker container. The container is created using the image ghcr.io/apache/airflow/main/ci/python3.9 from apache/airflow. Inside the container, airflow and python are installed:

$ which airflow
/usr/local/bin/airflow

$ which python
/usr/local/bin/python

I tried to execute this python script inside the container

$ /bin/python3 /files/dags/play.py
Traceback (most recent call last):
  File "/files/dags/play.py", line 1, in <module>
    from airflow import DAG
ModuleNotFoundError: No module named 'airflow'

2

Answers


  1. You are using /bin/python3 instead of /usr/local/bin/python.
    This can lead to the ModuleNotFoundError.

    Try this:

    /usr/local/bin/python /files/dags/play.py
    

    or

    python /files/dags/play.py
    
    Login or Signup to reply.
  2. You are using /bin/python3 instead of /usr/local/bin/python. This can lead to the ModuleNotFoundError.

    Try this:

    /usr/local/bin/python /files/dags/play.py

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search