我已经使用virtualenv -p $(which python3) ENV为python3创建了virtualenv
然后激活源source /Users/myusername/ENV/bin/activate
安装apache-airflow:
pip install apache-airflow然后which airflow会生成/Users/myusername/ENV/bin/airflow,但当我尝试使用以下命令初始化数据库时:
airflow initdb我得到下面的错误:
{db.py:350} INFO - Creating tables
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
WARNI [airflow.utils.log.logging_mixin.LoggingMixin] cryptography not found - values will not be stored encrypted.
ERROR [airflow.models.DagBag] Failed to import: /Library/Python/2.7/site-packages/airflow/example_dags/example_http_operator.py
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/airflow/models/__init__.py", line 413, in process_file
m = imp.load_source(mod_name, filepath)
File "/Library/Python/2.7/site-packages/airflow/example_dags/example_http_operator.py", line 27, in <module>
from airflow.operators.http_operator import SimpleHttpOperator
File "/Library/Python/2.7/site-packages/airflow/operators/http_operator.py", line 21, in <module>
from airflow.hooks.http_hook import HttpHook
File "/Library/Python/2.7/site-packages/airflow/hooks/http_hook.py", line 23, in <module>
import tenacity
File "/Library/Python/2.7/site-packages/tenacity/__init__.py", line 375, in <module>
from tenacity.tornadoweb import TornadoRetrying
File "/Library/Python/2.7/site-packages/tenacity/tornadoweb.py", line 24, in <module>
from tornado import gen
File "/Library/Python/2.7/site-packages/tornado-6.0.3-py2.7-macosx-10.14-intel.egg/tornado/gen.py", line 126
def _value_from_stopiteration(e: Union[StopIteration, "Return"]) -> Any:
^
SyntaxError: invalid syntax
Done.
(ENV) ---------------------------------------------------------看起来示例脚本使用的是python2.7,它不能识别函数定义语法。apache-airflow包是否需要在下一个版本中修复,或者我可以做些什么来修复这个问题?我尝试修复这个问题:使用python2.7而不是python3,然后在默认的python2.7上安装airflow,但是这会抛出其他错误,比如包"six“不兼容。
发布于 2019-07-13 20:09:22
要解决此问题,需要关闭要在配置文件中加载的示例DAG。
无论如何,当你告诉airflow是安装在Python3虚拟环境中时,它使用的是2.7Python,这似乎很奇怪。
https://stackoverflow.com/questions/56976527
复制相似问题