我已经按照步骤从下面的链接安装Airflow
Airflow installation并得到以下错误
Traceback (most recent call last):
File "/usr/local/bin/airflow", line 25, in <module>
from airflow.configuration import conf
File "/usr/local/lib/python3.5/dist-packages/airflow/__init__.py", line 42, in <module>
from airflow.models import DAG
File "/usr/local/lib/python3.5/dist-packages/airflow/models/__init__.py", line 21, in
<module>
from airflow.models.baseoperator import BaseOperator, BaseOperatorLink # noqa: F401
File "/usr/local/lib/python3.5/dist-packages/airflow/models/baseoperator.py", line 30, in
<module>
from typing import Any, Callable, ClassVar, Dict, FrozenSet, Iterable, List, Optional,
Set, Type, Union
ImportError: cannot import name 'ClassVar'
有人可以在这里帮我吗
答案 0 :(得分:6)
我也遇到相同的错误:
经过一番检查,我发现这是一个python版本的问题,即python3.5不支持模块键入。ClassVar:https://docs.python.org/3.5/library/typing.html
As introduced in PEP 526, a variable annotation wrapped in ClassVar indicates that a given attribute is intended to be used as a class variable and should not be set on instances of that class.
并检查了PEP 526,发现该功能仅从3.6开始支持,哦。
因此,解决方案是将Python版本升级到3.6+,以安装Airflow 1.10。
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.7
sudo apt install build-essential libssl-dev libffi-dev python3.7-dev
sudo apt-get install python3.7-venv
以上所有步骤均成功执行。 为了完善官方指南,安装环境要求如下: