Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Airflow : airflow initdb results in "ImportError: No module named json"

On Ubuntu 16.04 with Python 2.7 default version, I am trying to install Apache airflow but ran into several issues and currently I see on

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


Tried these things till now:


$ 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

Also tried

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()

Nothing worked so far.

like image 738
Vizag Avatar asked Jul 07 '19 14:07

Vizag


2 Answers

Just upgrade flask. You can use this command:

sudo pip install --upgrade Flask

like image 135
Israel Martínez García Avatar answered Nov 08 '22 12:11

Israel Martínez García


The problem is known, and is described here, in the ASF Mail Archives

We removed the incompatible Werkzeug library from apache master this weekend. It caused Airflow installations to fail.

To resolve, manually install the werkzeug library in a correct version:

pip install werkzeug>=0.15.0

As explained in the mail list, this seems to be a temporary problem, and this solution is a workaround. The problem is encountered in version 1.10.3.

like image 5
Alexis Lessard Avatar answered Nov 08 '22 14:11

Alexis Lessard