Getting-started-python: bookshelf error on App Engine: "ImportError: cannot import name 'secure_filename' from 'werkzeug'"

Created on 11 Feb 2020  路  7Comments  路  Source: GoogleCloudPlatform/getting-started-python

Manifests in App Engine by showing:

502 Bad Gateway
nginx

Look in the logs, to see the whole traceback:

Traceback (most recent call last):
File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process()
File "/env/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 104, in init_process super(ThreadWorker, self).init_process()
File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process self.load_wsgi()
File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi self.wsgi = self.app.wsgi()
File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load()
File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load return self.load_wsgiapp()
File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp return util.import_app(self.app_uri)
File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app __import__(module)
File "/srv/main.py", line 22, in import storage
File "/srv/storage.py", line 23, in from werkzeug import secure_filename ImportError: cannot import name 'secure_filename' from 'werkzeug' (/env/lib/python3.7/site-packages/werkzeug/__init__.py)

The Fix seems to be to replace line 23 in storage.py:

from werkzeug import secure_filename

with:

from werkzeug.utils import secure_filename

I've already tested the fix. I'm going to propose a PR.

triage me

Most helpful comment

You should use
from werkzeug.utils import secure_filename

All 7 comments

Merge fixed issue in my testing.

it appears that a temporary workaround is to revert werkzeug to v0.16.1:

https://github.com/puckel/docker-airflow/issues/499#issue-561766591

You should use
from werkzeug.utils import secure_filename

@galeanodairo thats worked, change the from werkzeug import secure_filename tofrom werkzeug.utils import secure_filename. Thanks!

You should use
from werkzeug.utils import secure_filename

tx brother

You should use
from werkzeug.utils import secure_filename

Thanks.

Was this page helpful?
0 / 5 - 0 ratings