superset: ModuleNotFoundError: No module named 'werkzeug.wrappers.etag'

ModuleNotFoundError: No module named ‘werkzeug.wrappers.etag’ #20723

How to reproduce the bug

Install using pip on Ubuntu with python 3.9

Get to this point as per instructions:

$HOME/venv/superset/2.0.0/bin/superset db upgrade

Expected results

No error

Actual results

logging was configured successfully
2022-07-15 15:10:24,707:INFO:superset.utils.logging_configurator:logging was configured successfully
2022-07-15 15:10:24,713:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
Falling back to the built-in cache, that stores data in the metadata database, for the following cache: `FILTER_STATE_CACHE_CONFIG`. It is recommended to use `RedisCache`, `MemcachedCache` or another dedicated caching backend for production deployments
2022-07-15 15:10:24,716:WARNING:superset.utils.cache_manager:Falling back to the built-in cache, that stores data in the metadata database, for the following cache: `FILTER_STATE_CACHE_CONFIG`. It is recommended to use `RedisCache`, `MemcachedCache` or another dedicated caching backend for production deployments
Falling back to the built-in cache, that stores data in the metadata database, for the following cache: `EXPLORE_FORM_DATA_CACHE_CONFIG`. It is recommended to use `RedisCache`, `MemcachedCache` or another dedicated caching backend for production deployments
2022-07-15 15:10:24,720:WARNING:superset.utils.cache_manager:Falling back to the built-in cache, that stores data in the metadata database, for the following cache: `EXPLORE_FORM_DATA_CACHE_CONFIG`. It is recommended to use `RedisCache`, `MemcachedCache` or another dedicated caching backend for production deployments
Failed to create app
Traceback (most recent call last):
  File "$HOME/venv/superset/2.0.0/lib/python3.9/site-packages/superset/app.py", line 37, in create_app
    app_initializer.init_app()
  File "$HOME/venv/superset/2.0.0/lib/python3.9/site-packages/superset/initialization/__init__.py", line 460, in init_app
    self.init_app_in_ctx()
  File "$HOME/venv/superset/2.0.0/lib/python3.9/site-packages/superset/initialization/__init__.py", line 409, in init_app_in_ctx
    self.configure_url_map_converters()
  File "$HOME/venv/superset/2.0.0/lib/python3.9/site-packages/superset/initialization/__init__.py", line 508, in configure_url_map_converters
    from superset.utils.url_map_converters import (
  File "$HOME/venv/superset/2.0.0/lib/python3.9/site-packages/superset/utils/url_map_converters.py", line 21, in <module>
    from superset.models.tags import ObjectTypes
  File "$HOME/venv/superset/2.0.0/lib/python3.9/site-packages/superset/models/__init__.py", line 17, in <module>
    from . import core, datasource_access_request, dynamic_plugins, sql_lab, user_attributes
  File "$HOME/venv/superset/2.0.0/lib/python3.9/site-packages/superset/models/core.py", line 63, in <module>
    from superset.utils import cache as cache_util, core as utils
  File "$HOME/venv/superset/2.0.0/lib/python3.9/site-packages/superset/utils/cache.py", line 28, in <module>
    from werkzeug.wrappers.etag import ETagResponseMixin
ModuleNotFoundError: No module named 'werkzeug.wrappers.etag'

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 27 (7 by maintainers)

Most upvoted comments

A hack to get around it:

python3 -m pip uninstall -y Werkzeug
python3 -m pip install Werkzeug==2.0.3

If there’s one thing you can reply on with a superset release is dodgy pip deps.

@dpgaspar thanks a lot for pointing that out!

Was facing the same problem. Running 1.5.0, upgrading to 2.0.0.

My solution was:

wget -O- https://raw.githubusercontent.com/apache/superset/2.0.0/requirements/base.txt | tail -n +10 > superset_requirements.txt
pip install apache-superset==2.0.0 -r superset_requirements.txt

This requirements/base.txt assumes a development environment (considering the -e file:. in there), and that was causing conflicts with my installation setup. tail in my command is to skip those lines.

After that I could move forward with applying db migrations successfully 😃

@trimat1 , I couldn’t get 22.04 to work whatsoever… python 3.10 has some breaking changes in the dependencies superset uses…

I backed down to 20.04 and did this routine to get setup, remove the sudo -u ubuntu … I use Juju and that runs as Root by default which I do not want for Superset

apt-get update
apt-get -y upgrade
apt-get -y install build-essential libssl-dev libffi-dev python3-dev python3-pip libsasl2-dev libldap2-dev default-libmysqlclient-dev libpq-dev python-is-python3

pip install --upgrade pip
sudo -u ubuntu pip install --upgrade pip --no-warn-script-location
sudo -u ubuntu pip install werkzeug==2.0.3 --no-warn-script-location
sudo -u ubuntu pip install flask==2.1.3 --no-warn-script-location
sudo -u ubuntu pip install wtforms==2.3.0 --no-warn-script-location
sudo -u ubuntu pip install --upgrade pyopenssl --no-warn-script-location
sudo -u ubuntu pip install psycopg2-binary pillow gunicorn gevent --no-warn-script-location

sudo -u ubuntu pip install sqlalchemy-trino pyhive --no-warn-script-location
sudo -u ubuntu pip install apache-superset --no-warn-script-location

sudo touch /etc/profile.d/superset.sh
echo -e 'export FLASK_APP=superset' >> /etc/profile.d/superset.sh
  
export FLASK_APP=superset
sudo -u ubuntu FLASK_APP=superset /home/ubuntu/.local/bin/superset db upgrade
sudo -u ubuntu FLASK_APP=superset /home/ubuntu/.local/bin/superset fab create-admin --username admin --firstname admin --lastname user --email admin@some.co --password YOURFAVORITEPASSWORDHERE 

install_example_data="$(config-get install_example_data)"
if $install_example_data; then
  sudo -u ubuntu FLASK_APP=superset /home/ubuntu/.local/bin/superset load_examples
else
  juju-log -l "WARNING" "Forgoing superset load_examples"
  status-set maintenance "Forgoing superset load_examples $(date +"%H:%M")"
fi
sudo -u ubuntu FLASK_APP=superset /home/ubuntu/.local/bin/superset init

Hi @EMCP , i finally managed to run it.

pip uninstall -y markupsafe
pip install markupsafe==2.0.1
pip uninstall -y Werkzeug
pip install Werkzeug==2.0.3
pip uninstall WTForms 
pip install WTForms==2.3.0

this is whats was needed (hopefully). installed and uninstalled a dozen of packages, but these might be the relevant ones.

wget -O- https://raw.githubusercontent.com/apache/superset/2.0.0/requirements/base.txt[](https://raw.githubusercontent.com/apache/superset/2.0.0/requirements/base.txt) | tail -n +10 > superset_requirements.txt
pip install apache-superset==2.0.0 -r superset_requirements.txt

I made a variant of the command @WesleyBatista made, since the one he shared creates a file which isn’t necessary:

curl -sS https://raw.githubusercontent.com/apache/superset/2.0.0/requirements/base.txt | tail -n +10 | awk -v ORS=" " '/^[A-z]/{print}' | xargs pip install apache-superset==2.0.0

Seems like ETagResponseMixin was removed here: https://github.com/pallets/werkzeug/pull/2276 it was deprecated, we should update our etag_cache method accordingly.

Do note that production Superset installations should use pinned dependencies based on: https://github.com/apache/superset/blob/master/requirements/base.txt

@dat-linux I installed Flask == 2.1.0

Fixed as per the above commit.

I’m just the Ubuntu messenger. I cannot speak for Mac.

I recommend trying to install on a fresh Ubuntu 22.04 using pip install and you’ll see the problems. It comes with python 3.10, and this results in a failure based on a couple of problematic deps (see below).

Even when I install python 3.9 alongside, I get the error described above.

In order to overcome ALL issues I encountered I need to perform:

  • Python 3.9 install using pyenv (and run pip install apache-superset using the 3.9 binary) And immediately after that:
- python3.9 -m pip uninstall -y markupsafe
- python3.9 -m pip install markupsafe==2.0.1
- python3.9 -m pip uninstall -y Werkzeug
- python3.9 -m pip install Werkzeug==2.0.3

The above needs to be done before the superset db upgrade step.

Just reporting as I see it based on a fresh install of Ubuntu 22.04 (with all system updates applied). Issues re markupsafe, and 3.10 failure (it results in an error when building the pyarrow pkg) have been reported elsewhere on this message board.

@trimat1 , I couldn’t get 22.04 to work whatsoever… python 3.10 has some breaking changes in the dependencies superset uses…

I backed down to 20.04 and did this routine to get setup, remove the sudo -u ubuntu … I use Juju and that runs as Root by default which I do not want for Superset

apt-get update
apt-get -y upgrade
apt-get -y install build-essential libssl-dev libffi-dev python3-dev python3-pip libsasl2-dev libldap2-dev default-libmysqlclient-dev libpq-dev python-is-python3

pip install --upgrade pip
sudo -u ubuntu pip install --upgrade pip --no-warn-script-location
sudo -u ubuntu pip install werkzeug==2.0.3 --no-warn-script-location
sudo -u ubuntu pip install flask==2.1.3 --no-warn-script-location
sudo -u ubuntu pip install wtforms==2.3.0 --no-warn-script-location
sudo -u ubuntu pip install --upgrade pyopenssl --no-warn-script-location
sudo -u ubuntu pip install psycopg2-binary pillow gunicorn gevent --no-warn-script-location

sudo -u ubuntu pip install sqlalchemy-trino pyhive --no-warn-script-location
sudo -u ubuntu pip install apache-superset --no-warn-script-location

sudo touch /etc/profile.d/superset.sh
echo -e 'export FLASK_APP=superset' >> /etc/profile.d/superset.sh
  
export FLASK_APP=superset
sudo -u ubuntu FLASK_APP=superset /home/ubuntu/.local/bin/superset db upgrade
sudo -u ubuntu FLASK_APP=superset /home/ubuntu/.local/bin/superset fab create-admin --username admin --firstname admin --lastname user --email admin@some.co --password YOURFAVORITEPASSWORDHERE 

install_example_data="$(config-get install_example_data)"
if $install_example_data; then
  sudo -u ubuntu FLASK_APP=superset /home/ubuntu/.local/bin/superset load_examples
else
  juju-log -l "WARNING" "Forgoing superset load_examples"
  status-set maintenance "Forgoing superset load_examples $(date +"%H:%M")"
fi
sudo -u ubuntu FLASK_APP=superset /home/ubuntu/.local/bin/superset init

Well, the original issue was found due to an attempt to install Superset on Ubuntu 22.04.

Collecting pyarrow==5.0.0
  Downloading pyarrow-5.0.0.tar.gz (739 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 739.1/739.1 kB 4.4 MB/s eta 0:00:00
  Installing build dependencies ... error
  error: subprocess-exited-with-error
  
  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [945 lines of output]
      Ignoring numpy: markers 'python_version < "3.9"' don't match your environment

Install still fails on platforms that have Python 3.10 by default (ie Ubuntu 22.04).

can confirm it is indeed happening inside my LXC 20.04 container

python is 3.8.10 with latest pip