Apache Airflow:气流initdb导致“ ImportError:没有名为json的模块”

时间:2019-07-07 14:27:24

标签: json python-2.7 ubuntu-16.04 airflow

在具有Python 2.7默认版本的Ubuntu 16.04上,我正在尝试安装Apache airflow,但是遇到了几个问题,目前我能看到

apache initdb 
Traceback (most recent call last):
  File "/usr/local/bin/airflow", line 21, in <module>
    from airflow import configuration
  File "/usr/local/lib/python2.7/dist-packages/airflow/__init__.py", line 40, in <module>
    from flask_admin import BaseView
  File "/usr/local/lib/python2.7/dist-packages/flask_admin/__init__.py", line 6, in <module>
    from .base import expose, expose_plugview, Admin, BaseView, AdminIndexView  # noqa: F401
  File "/usr/local/lib/python2.7/dist-packages/flask_admin/base.py", line 6, in <module>
    from flask import Blueprint, current_app, render_template, abort, g, url_for
  File "/usr/local/lib/python2.7/dist-packages/flask/__init__.py", line 20, in <module>
    from .app import Flask
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 69, in <module>
    from .wrappers import Request
  File "/usr/local/lib/python2.7/dist-packages/flask/wrappers.py", line 14, in <module>
    from werkzeug.wrappers.json import JSONMixin as _JSONMixin
ImportError: No module named json


到目前为止,已经尝试过这些事情:


$ sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev
sudo pip install -U Werkzeug==0.14.1

sudo pip install -U Jinja2==2.10.1

也尝试过

pip install jsonate

pip install json # (this did not work)

 python
Python 2.7.12 (default, Nov 12 2018, 14:36:49)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> exit()

到目前为止什么都没做。

4 个答案:

答案 0 :(得分:8)

只需升级烧瓶。您可以使用以下命令:

pip install --upgrade Flask

答案 1 :(得分:4)

已知问题,并在ASF Mail Archives

中对此问题进行了描述。
  

我们从apache master移除了不兼容的Werkzeug库   周末。它导致气流安装失败。

要解决此问题,请以正确的版本手动安装werkzeug库:

pip install werkzeug>=0.15.0

如邮件列表中所述,这似乎是暂时的问题,此解决方案是一种解决方法。在1.10.3版中遇到此问题。

答案 2 :(得分:1)

在Mac上安装apache-airflow时,出现以下错误:

错误:apache-airflow 1.10.3要求jinja2 <= 2.10.0,> = 2.7.3,但您将拥有不兼容的jinja2 2.10.1。 错误:apache-airflow 1.10.3要求werkzeug <0.15.0,> = 0.14.1,但是您将拥有不兼容的werkzeug 0.15.4。

重新安装werkzeug和jinja对我有用。

pip install jinja2>=2.10.0
pip install werkzeug>=0.15.0

答案 3 :(得分:0)

sudo pip install --upgrade Flask对我有用