airflow initdb: ImportError: cannot import name 'HTMLString'

夙愿已清 提交于 2020-05-16 02:45:08

问题


I'm getting ImportError: cannot import name 'HTMLString' on running 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

回答1:


The recent release of WTForms broke Airflow. You have 2 options:

1) Install it with constraints

For 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

For 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) Pin WTForms

pip install wtforms==2.3.1 



回答2:


It's related to latest wtforms release, you can see the details in https://github.com/apache/airflow/issues/8506.

Run the

pip install wtforms<2.3.0 

before installing airflow, so this dependency is met by airflow and the upgraded package is not installed.



来源:https://stackoverflow.com/questions/61362750/airflow-initdb-importerror-cannot-import-name-htmlstring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!