admin管理员组

文章数量:1122846

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'

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'
Share Improve this question asked Nov 23, 2024 at 5:08 Rebel AIRebel AI 291 silver badge2 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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

or

python /files/dags/play.py

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

本文标签: linuxPython ModuleNotFoundError inside Docker containerStack Overflow