dash
dash copied to clipboard
[BUG] Flask 2.2.0 unbound_message error.
Describe your context Environment currently running in Docker, with the following Dockerfiles:
Our ubuntu:latest dockerfile:
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND="noninteractive"
LC_ALL="en_US.UTF-8"
LANG="en_US.UTF-8"
LANGUAGE="en_US.UTF-8"
RUN apt-get update &&
apt-get upgrade -y &&
apt-get install -y ca-certificates tzdata locales &&
update-ca-certificates -f &&
rm /etc/timezone &&
rm /etc/localtime &&
echo "Europe/Berlin" | tee /etc/timezone &&
ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime &&
dpkg-reconfigure --frontend noninteractive tzdata &&
locale-gen en_US.UTF-8 &&
echo "LC_ALL=en_US.UTF8" > /etc/default/locale &&
echo "LANG=en_US.UTF8" >> /etc/default/locale &&
echo "LC_CTYPE=en_US.UTF8" >> /etc/default/locale &&
echo "LC_COLLATE=en_US.UTF8" >> /etc/default/locale &&
chmod 0755 /etc/default/locale
Our python:latest dockerfile:
FROM **/base-images/ubuntu:latest
ADD pip.conf /etc/pip.conf
ENV REQUESTS_CA_BUNDLE="/etc/ssl/certs/ca-certificates.crt"
PIP_DEFAULT_TIMEOUT=120
RUN apt-get update &&
apt-get install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev curl &&
mkdir /tempdir &&
cd /tempdir &&
curl https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tgz -o python.tgz &&
tar -xvzf python.tgz &&
cd Python-3.10.2 &&
./configure --enable-optimizations &&
make &&
make install &&
cd &&
rm -rf /tempdir &&
python3 -m pip install --upgrade pip &&
pip3 install requests &&
apt-get remove -y curl wget
USER app
WORKDIR /app
ENV PATH="${PATH}:/app/.local/bin/"
CMD ["/usr/bin/python3"]
Our dash:latest dockerfile:
FROM **/base-images/python:latest USER root RUN pip3 install dash dash-renderer dash-html-components dash-core-components plotly gunicorn Flask EXPOSE 5000 USER app COPY *.py /app/ CMD ["gunicorn", "--workers", "1", "--bind", "0.0.0.0:5000", "--timeout", "100000", "--max-requests", "20", "--access-logfile", "-", "--error-logfile", "-", "--capture-output", "application:server"]
Our docker file:
FROM **/base-images/dash:latest
EXPOSE 5000
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:5000", "-t", "0", "--max-requests", "0", "--access-logfile", "-", "--error-logfile", "-", "--capture-output", "index:server"]
USER root
COPY requirements.txt /tmp/
RUN pip3 install -r /tmp/requirements.txt &&
rm /tmp/requirements.txt
USER app
COPY . /app
- replace the result of
pip list | grep dashbelow
dash 2.0.0
dash-bootstrap-components 0.11.4rc3
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table 5.0.0
Describe the bug
I am not able to start my app, I get the following error:
[2022-08-08 11:24:34 +0200] [1] [INFO] Starting gunicorn 20.0.4
[2022-08-08 11:24:34 +0200] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
[2022-08-08 11:24:34 +0200] [1] [INFO] Using worker: sync
[2022-08-08 11:24:34 +0200] [8] [INFO] Booting worker with pid: 8
[2022-08-08 11:24:34 +0200] [9] [INFO] Booting worker with pid: 9
[2022-08-08 11:24:34 +0200] [10] [INFO] Booting worker with pid: 10
[2022-08-08 11:24:34 +0200] [8] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.8/dist-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.8/dist-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.8/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.8/dist-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.8/dist-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.8/dist-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
File "/usr/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "
Expected behavior
Starting of the server and listening to port in localhost.
Thank you very much for the help!
This line is the error:
got an unexpected keyword argument 'unbound_message'
Related to flask 2.2.0, you can pin earlier version of flask to fix the issue in the meantime.
Generally though people are able to use Dash with Flask 2.2 (eg https://github.com/plotly/dash/issues/2177) - so is there something else required to generate this problem, some other pinned dependency?
It's werkzeug version mismatch, flask 2.2.x needs werkzeug 2.2.x
I've also had a report of this error coming up with a slightly different stack trace:
“Traceback (most recent call last):
File "/workspace/app.py", line 2, in <module>
import dash
File "/app/.heroku/python/lib/python3.9/site-packages/dash/__init__.py", line 5, in <module>
from .dash import Dash, no_update # noqa: F401,E402
File "/app/.heroku/python/lib/python3.9/site-packages/dash/dash.py", line 17, in <module>
import flask
File "/app/.heroku/python/lib/python3.9/site-packages/flask/__init__.py", line 4, in <module>
from . import json as json
File "/app/.heroku/python/lib/python3.9/site-packages/flask/json/__init__.py", line 8, in <module>
from ..globals import current_app
File "/app/.heroku/python/lib/python3.9/site-packages/flask/globals.py", line 56, in <module>
app_ctx: "AppContext" = LocalProxy( # type: ignore[assignment]
TypeError: __init__() got an unexpected keyword argument 'unbound_message'”
Downgrading Flask resolved this. @T4rk1n do you think this is the same version mismatch problem?
@hannahker Yes, this happen when flask 2.2.x is installed but not werkzeug, possibly because werkzeug version was locked in requirements.txt but not flask