Airflow &引用;没有名为“气流”的模块;使用PythonVirtualenvOperator在导入的Utils模块中使用气流类时
我有我的utils文件(在PYTHONPATH中)Airflow &引用;没有名为“气流”的模块;使用PythonVirtualenvOperator在导入的Utils模块中使用气流类时,airflow,Airflow,我有我的utils文件(在PYTHONPATH中) #utils.py 从airflow.hooks.base导入BaseHook 作为pd进口熊猫 def get_cred(): con=BaseHook.get\u连接(“我的\u-con”) #一些数据操作 返回df 我的任务 #task.py def get_data(): from utils import get_cred df = get_cred() . . #the rest of the funct
#utils.py
从airflow.hooks.base导入BaseHook
作为pd进口熊猫
def get_cred():
con=BaseHook.get\u连接(“我的\u-con”)
#一些数据操作
返回df
我的任务
#task.py
def get_data():
from utils import get_cred
df = get_cred()
.
. #the rest of the function
最后是我的狗
#dag.py
从afflow.operators.python导入pythonvirtualenvooperator
表单导入DAG
从任务导入获取数据
dag=dag(…)
t1=PythonVirtualenvOperator(
python_version=“3.7”,
要求=[“熊猫”、“pyodbc”、“SQLaclhemy”],
python\u callable=get\u data,
dag=dag)
t1
从utils import get_data运行DAG失败,错误为没有名为airflow的模块。
我试着添加``
我可以通过在我的需求中添加apacheairflow
来克服这个问题,但是由于它是一个相当庞大的包,所以它会大大增加运行时间