如何导入Airflow的PostgresOperator

Lea*_*dro 5 python airflow

PostgresOperator我正在尝试从气流包导入:

from airflow.providers.postgres.operators.postgres import PostgresOperator
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:Cannot find reference 'postgres' in imported module airflow.providers

Lea*_*dro 7

解决方案是使用项目的 virtualenv: 在终端中运行以下命令pip install 'apache-airflow[postgres]'

请注意,如果不将包的名称放在单引号之间,它将不起作用。