问题描述
我最近为工作流程安装了 airflow
。在创建项目时,我执行了以下命令:
I have recently installed airflow
for my workflows. While creating my project, I executed following command:
airflow initdb
返回以下错误:
[2016-08-15 11:17:00,314] {__init__.py:36} INFO - Using executor SequentialExecutor
DB: sqlite:////Users/mikhilraj/airflow/airflow.db
[2016-08-15 11:17:01,319] {db.py:222} INFO - Creating tables
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
ERROR [airflow.models.DagBag] Failed to import: /usr/local/lib/python2.7/site-packages/airflow/example_dags/example_twitter_dag.py
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/airflow/models.py", line 247, in process_file
m = imp.load_source(mod_name, file path)
File "/usr/local/lib/python2.7/site-packages/airflow/example_dags/example_twitter_dag.py", line 26, in <module>
from airflow.operators import BashOperator, HiveOperator, PythonOperator
ImportError: cannot import name HiveOperator
Done.
我在网上检查了一些类似的问题,建议我安装 airflow [蜂箱]
, pyhs2
,但似乎不起作用。
I checked some similar issues on web, which suggested me to install airflow[hive]
, pyhs2
but it doesn't seem to work.
推荐答案
您是否正在使用 HiveOperator
?您似乎收到的错误是由于示例dags中的1个引起的。在生产中,您应该将 load_examples
设置为 False
并安装 airflow [hive]
Are you using the
HiveOperator
? It seems like the error you are getting is due to 1 of the example dags. In production you should probably set load_examples
to False
and install airflow[hive]
only if you are using the HiveOperator.
话虽如此,不确定为什么
airflow [hive]
对您来说还不够。您可以尝试安装 airflow [hive,hdfs,jdbc]
,但是气流[hive]应该足以摆脱 HiveOperator
导入错误。您能否加上遇到的其他错误?
That being said, not sure why
airflow[hive]
isn't enough for you. You may try installing airflow[hive,hdfs,jdbc]
but the airflow[hive] should be enough to get rid of the HiveOperator
import error. Could you perhaps add what other error you are getting?
这篇关于当气流为initdb时,ImportError:无法导入名称HiveOperator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!