气流initdb:ImportError:无法导入名称“ HTMLString”

时间:2020-04-22 10:23:53

标签: python-3.x airflow

我在运行ImportError: cannot import name 'HTMLString'时得到airflow initdb

File "/home/ubuntu/airflow_env/bin/airflow", line 26, in <module>
    from airflow.bin.cli import CLIFactory
  File "/home/ubuntu/airflow_env/lib/python3.6/site-packages/airflow/bin/cli.py", line 71, in <module>
    from airflow.www_rbac.app import cached_app as cached_app_rbac
  File "/home/ubuntu/airflow_env/lib/python3.6/site-packages/airflow/www_rbac/app.py", line 27, in <module>
    from flask_appbuilder import AppBuilder, SQLA
  File "/home/ubuntu/airflow_env/lib/python3.6/site-packages/flask_appbuilder/__init__.py", line 6, in <module>
    from .base import AppBuilder  # noqa: F401
  File "/home/ubuntu/airflow_env/lib/python3.6/site-packages/flask_appbuilder/base.py", line 8, in <module>
    from .api.manager import OpenApiManager
  File "/home/ubuntu/airflow_env/lib/python3.6/site-packages/flask_appbuilder/api/manager.py", line 7, in <module>
    from flask_appbuilder.baseviews import BaseView
  File "/home/ubuntu/airflow_env/lib/python3.6/site-packages/flask_appbuilder/baseviews.py", line 21, in <module>
    from .forms import GeneralModelConverter
  File "/home/ubuntu/airflow_env/lib/python3.6/site-packages/flask_appbuilder/forms.py", line 17, in <module>
    from .fieldwidgets import (
  File "/home/ubuntu/airflow_env/lib/python3.6/site-packages/flask_appbuilder/fieldwidgets.py", line 3, in <module>
    from wtforms.widgets import html_params, HTMLString
ImportError: cannot import name 'HTMLString'
  • apache-airflow == 1.10.9,SQLAlchemy == 1.3.15

2 个答案:

答案 0 :(得分:2)

WTForms的recent release破坏了气流。您有2个选择:

1)安装时受限制

对于 Python 3.7

pip install apache-airflow==1.10.9 \
   --constraint https://raw.githubusercontent.com/apache/airflow/1.10.10/requirements/requirements-python3.7.txt

对于 Python 3.6

pip install apache-airflow==1.10.9 \
   --constraint https://raw.githubusercontent.com/apache/airflow/1.10.10/requirements/requirements-python3.6.txt

2)固定WTForms

pip install wtforms==2.3.1 

答案 1 :(得分:1)

它与最新的wtforms版本有关,您可以在https://github.com/apache/airflow/issues/8506中查看详细信息。

运行

pip install wtforms<2.3.0 

在安装气流之前,因此气流会满足这种依赖性,并且不会安装升级的软件包。