You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Airflow运行DAG时提示ModuleNotFoundError: No module named 'pandas'的问题求助

Airflow运行DAG时提示ModuleNotFoundError: No module named 'pandas'的问题求助

我现在在搭建一个用到pandas的Airflow DAG,但Airflow WebUI一直报错说找不到pandas模块。我已经在本地Windows和启用WSL的Ubuntu上都安装了pandas,在这两个环境的Python里导入pandas都能正常工作,也能看到对应的版本:

Windows环境验证

Windows环境下pandas版本验证

Ubuntu环境验证

Ubuntu环境下pandas版本验证

以下是我的DAG代码:

import requests as re 
from io import StringIO as si
from airflow import DAG 
from airflow.operators.python import PythonOperator
import pandas as pd
from datetime import datetime, timedelta
import sys
import os

sys.path.insert(0,os.path.abspath(os.path.dirname(__file__)))

default_args = {
    'owner' : '****',
    'retires' : 5,
    'retry_delay' : timedelta(minutes=3)
}
 

def fetch_data():
    url = re.get("https://catalog.ourworldindata.org/explorers/who/latest/monkeypox/monkeypox.csv")
    if url.status_code == 200:
        csv_data=si(url.text)
        df = pd.read_csv(csv_data, low_memory=False)

    new_df = df[['location', 'date', 'iso_code', 'total_cases', 'total_deaths', 'new_cases', 'new_deaths']]
    print(new_df.shape)


with DAG(
    default_args=default_args,
    dag_id='owid_data_pipeline',
    description='DAG to fetch and load owid mpox daily data into postgres',
    start_date=datetime(2024, 12, 18),
    schedule_interval='@daily'
) as dag : 
    task1 = PythonOperator(
            task_id='fetch_data',
            python_callable=fetch_data
        )


task1

运行时出现的错误如下:
Airflow报错:ModuleNotFoundError: No module named 'pandas'

我已经卡了一整天了,麻烦各位大佬给点建议,谢谢!

备注:内容来源于stack exchange,提问作者blackishgray

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 16:53:06