ImportError: No module named 'werkzeug.wrappers.json'; 'werkzeug.wrappers' is not a package

Issue

I’m getting this error when trying to use Airflow on WSL. Not sure what the issue is - I upgraded Flask & werkzeug.

File "/usr/local/bin/airflow", line 21, in <module> from airflow import configuration
File "/usr/local/lib/python3.5/dist-packages/airflow/__init__.py", line 40, in <module> from flask_admin import BaseView
File "/usr/local/lib/python3.5/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/python3.5/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/python3.5/dist-packages/flask/__init__.py", line 21, in <module> from .app import Flask
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 69, in <module> from .wrappers import Request
File "/usr/local/lib/python3.5/dist-packages/flask/wrappers.py", line 14, in <module> from werkzeug.wrappers.json import JSONMixin as _JSONMixin

ImportError: No module named 'werkzeug.wrappers.json';  **'werkzeug** .wrappers' is not a package

Fix

This is a bug that got introduce into Flask and worked its way into Airflow and one of our Docker images. You’ll need to do 1 of 2 things:

  1. Change the Dockerfile to FROM Quay

OR

  1. In requirements.txt, pin Flask to “Flask=1.0.0”

This bug should be resolved by this PR in Airflow 1.10.4.

Ref: https://lists.apache.org/x/thread.html/fdb24fe0249b856926195cb19323383a4636ee0b0c398e376dce28ed@<dev.airflow.apache.org>

You can also set the werkzeug version to werkzeug>=0.15.0

2 Likes

Yes! This worked. I switched werkzeug to the latest available version and it worked.

1 Like