0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Airflow on Kubernetes】トラブルシューティング - k8sにDeployするとImportError: No module named json

Last updated at Posted at 2019-07-31

Airflow on Kubernetesで発生したエラーの内容と対策方法。

目次

発生バージョン

エラー内容

scripts/ci/kubernetes/kube/deploy.shを実行しPodを起動しようとすると、initContainersのcommandairflow initdbの処理で以下のエラーが出る。

+airflow 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

調査

scripts/ci/kubernetes/docker/Dockerfileをdocker buildすると以下のエラーが出る。

ERROR: flask 1.1.1 has requirement Jinja2>=2.10.1, but you'll have jinja2 2.10 which is incompatible.
ERROR: flask 1.1.1 has requirement Werkzeug>=0.15, but you'll have werkzeug 0.14.1 which is incompatible.
ERROR: pendulum 1.4.4 has requirement tzlocal<2.0.0.0,>=1.5.0.0, but you'll have tzlocal 2.0.0 which is incompatible.

原因

flask 1.1.1では、以下の3つのモジュールが下記のバージョンである必要があるが、1.10.3では古いものが定義されている。

  • jinja2>=2.10.0
  • tzlocal>=1.5.0.0, <2.0.0.0
  • werkzeug>=0.15.0

対策

setup.pydef do_setup()の部分を以下のように変更する。

diff --git a/setup.py b/setup.py
index 006de0a..95c40ae 100644
--- a/setup.py
+++ b/setup.py
@@ -307,7 +307,7 @@ def do_setup():
             'gunicorn>=19.5.0, <20.0',
             'iso8601>=0.1.12',
             'json-merge-patch==0.2',
-            'jinja2>=2.7.3, <=2.10.0',
+            'jinja2>=2.10.0',
             'lxml>=4.0.0',
             'markdown>=2.5.2, <3.0',
             'pandas>=0.17.1, <1.0.0',
@@ -324,9 +324,9 @@ def do_setup():
             'text-unidecode==1.2',
             'typing;python_version<"3.5"',
             'thrift>=0.9.2',
-            'tzlocal>=1.4',
+            'tzlocal>=1.5.0.0, <2.0.0.0',
             'unicodecsv>=0.14.1',
-            'werkzeug>=0.14.1, <0.15.0',
+            'werkzeug>=0.15.0',
             'zope.deprecation>=4.0, <5.0',
         ],
         setup_requires=[

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?