That exception looks like Flask-Uploads is trying to from werkzeug import secure_filename which should be from werkzeug.utils import secure_filename, as per your own code.

Going by the Flask-Uploads github repo this appears to have been fixed 12 months ago.

I'd try pip install -U flask-uploads in your virtual environment, to ensure the latest version.

EDIT:

As @mattficke points out, the PyPi version is dated, and there's not a more recent release on the repo. Turns out you can install directly based on a commit hash, so for the latest (at the time of writing this):

pip install git+https://github.com/maxcountryman/flask-uploads.git@f66d7dc

Or in a requirements.txt:

git+https://github.com/maxcountryman/flask-uploads.git@f66d7dc

Then pip install -r requirements.txt.

Which works wonders:

>>> from flask_uploads import UploadSet,configure_uploads,IMAGES,DATA,ALL
>>> # No Exception
Answer from v25 on Stack Overflow
🌐
GitHub
github.com › bigeyex › python-adminui › issues › 14
ImportError: cannot import name 'secure_filename' from 'werkzeug' · Issue #14 · bigeyex/python-adminui
September 21, 2020 - Meanwhile, the latest version of Werkzeug has moved secure_filename from being importable via werkzeug directly to now only being importable via werkzeug.utils.
Author   bigeyex
Discussions

bookshelf error on App Engine: "ImportError: cannot import name 'secure_filename' from 'werkzeug'"
Traceback (most recent call last): ... 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/i... More on github.com
🌐 github.com
7
February 11, 2020
Cannot import `secure_filename`
In [1]: import werkzeug In [2]: werkzeug.secure_filename --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) More on github.com
🌐 github.com
3
July 19, 2019
Import Error when importing secure_filename from Werkzeug.utils : Forums : PythonAnywhere
2020-06-09 19:19:39,700: Error ... cannot import name 'secure_filename' 2020-06-09 19:19:39,731: File "/var/www/virtualta_pythonanywhere_com_wsgi.py", line 16, in 2020-06-09 19:19:39,731: from flask_app import app as application # noqa 2020-06-09 19:19:39,731: 2020-06-09 19:19:39,731: File "/home/VirtualTA/mysite/flask_app.py", line 6, in 2020-06-09 19:19:39,731: from werkzeug.utils import ... More on pythonanywhere.com
🌐 pythonanywhere.com
werkzeug fails to import secure_filename within Docker
Traceback (most recent call last): ... "/usr/local/lib/python3.8/site-packages/flask_uploads.py", line 26, in from werkzeug import secure_filename, FileStorage ImportError: cannot import name 'secure_filename' from 'werkzeug' (/usr/local/lib/python3.8/site-packages/w... More on github.com
🌐 github.com
1
February 9, 2020
🌐
GitHub
github.com › GoogleCloudPlatform › getting-started-python › issues › 256
bookshelf error on App Engine: "ImportError: cannot import name 'secure_filename' from 'werkzeug'" · Issue #256 · GoogleCloudPlatform/getting-started-python
February 11, 2020 - Traceback (most recent call last): ... 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/i...
Author   GoogleCloudPlatform
🌐
GitHub
github.com › pallets › werkzeug › issues › 1616
Cannot import `secure_filename` · Issue #1616 · pallets/werkzeug
July 19, 2019 - In [1]: import werkzeug In [2]: werkzeug.secure_filename --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-2-1002393a11fd> in <module> ----> 1 werkzeug.secure_filename ~/pypath/werkzeug/__init__.py in __getattr__(self, name) 186 module = __import__(object_origins[name], None, None, [name]) 187 for extra_name in all_by_module[module.__name__]: --> 188 setattr(self, extra_name, getattr(module, extra_name)) 189 return getattr(module, name) 190 elif name in attribute_modules: AttributeError: module 'werkzeug.utils' has no attribute 'dump_cookie'
Author   pallets
🌐
PythonAnywhere
pythonanywhere.com › forums › topic › 27730
Import Error when importing secure_filename from Werkzeug.utils : Forums : PythonAnywhere
It looks like your code has been written to work with werkzeug 1.0, but is running with a different version. You can upgrade the version installed for your account easily; as your website is using Python 3.6 and is not using a virtualenv, just run this in bash: ... Thanks for sharing, @enzipe2. ...
🌐
GitHub
github.com › pallets › werkzeug › issues › 1724
werkzeug fails to import secure_filename within Docker · Issue #1724 · pallets/werkzeug
February 9, 2020 - Traceback (most recent call last): ... "/usr/local/lib/python3.8/site-packages/flask_uploads.py", line 26, in <module> from werkzeug import secure_filename, FileStorage ImportError: cannot import name 'secure_filename' from 'werkzeug' (/usr/local/lib/python3.8/site-packages/w...
Author   pallets
🌐
Beautiful Soup
tedboy.github.io › flask › generated › werkzeug.secure_filename.html
werkzeug.secure_filename — Flask API
The filename returned is an ASCII only string for maximum portability. On windows systems the function also makes sure that the file is not named after one of the special device files. >>> secure_filename("My cool movie.mov") 'My_cool_movie.mov' >>> secure_filename("../../../etc/passwd") 'etc_passwd' >>> secure_filename(u'i contain cool \xfcml\xe4uts.txt') 'i_contain_cool_umlauts.txt'
Find elsewhere
🌐
GitHub
github.com › chrissimpkins › crypto › issues › 23
Cannot import secure_filename from werkzeug · Issue #23 · chrissimpkins/crypto
February 5, 2020 - ImportError: cannot import name 'secure_filename' from 'werkzeug' (/root/.local/share/virtualenvs/eprocessify-backend-TPPgizr-/lib/python3.7/site-packages/werkzeug/__init__.py) But when I remove the code which uses crypto package and remove the crypto package, all works properly.
Author   chrissimpkins
🌐
GitHub
github.com › ovh › fiowebviewer › issues › 4
Cannot import secure_filename from werkzeug · Issue #4 · ovh/fiowebviewer
February 8, 2021 - # export FIOWEBVIEWER_SETTINGS=$(pwd)/config.cfg; python create_tables.py Traceback (most recent call last): File "create_tables.py", line 13, in <module> from fiowebviewer.engine.run import ( File "/opt/fiowebviewer/fiowebviewer/__init__.py", line 5, in <module> from fiowebviewer.engine.run import ( File "/opt/fiowebviewer/fiowebviewer/engine/run.py", line 38, in <module> from fiowebviewer.engine.view import * File "/opt/fiowebviewer/fiowebviewer/engine/view.py", line 21, in <module> from werkzeug import secure_filename ImportError: cannot import name 'secure_filename'
Author   ovh
🌐
GitHub
github.com › puckel › docker-airflow › issues › 499
Incompatible with newly released Werkzeug 1.0.0 · Issue #499 · puckel/docker-airflow
February 8, 2020 - v1.0.0 of Werkzeug was just released, and it now breaks builds with: ImportError: cannot import name 'secure_filename' from 'werkzeug' According to the changelog, top-level attributes were removed in 1.0: Deprecate most top-level attribu...
Author   puckel
🌐
Beautiful Soup
tedboy.github.io › flask › _modules › werkzeug › utils.html
werkzeug.utils — Flask API
For more advanced string formattings have a look at the `werkzeug.template` module. :param string: the format string. :param context: a dict with the variables to insert. """ def lookup_arg(match): x = context[match.group(1) or match.group(2)] if not isinstance(x, string_types): x = type(string)(x) return x return _format_re.sub(lookup_arg, string) [docs]def secure_filename(filename): r"""Pass it a filename and it will return a secure version of it.
🌐
GitHub
github.com › pallets › flask › issues › 1547
Quickstart > File Uploads > incorrect import: secure_filename · Issue #1547 · pallets/flask
August 2, 2015 - It should be imported as: from werkzeug.utils import secure_filename Not: from werkzeug import secure_filename see http://werkzeug.pocoo.org/docs/0.10/utils/
Author   pallets
🌐
Jugmac00
jugmac00.github.io › blogs › flask reuploaded
Flask Reuploaded | Jürgen Gmach
June 28, 2020 - It all started with this error message: File "/Projects/xxx/venv/lib/python3.7/site-packages/flask_uploads.py", line 26, in from werkzeug import secure_filename, FileStorage ImportError: cannot import name 'secure_filename' from 'werkzeug'' Trying to build my Flask application, the above error ...
🌐
Debug Lab
debuglab.net › home › flask_uploads: importerror: cannot import name ‘secure_filename’
Flask_Uploads: Importerror: Cannot Import Name 'Secure_Filename' - Debug Lab
August 10, 2023 - It’s understandable how one can get confused because multiple Flask extension libraries deal with file uploads and names. However, the ‘secure_filename’ function doesn’t actually belong to the ‘flask_uploads’ module, which is driving the ImportError. Instead, what you want to do is import it from the ‘werkzeug.utils‘ module:
🌐
Reddit
reddit.com › r/flask › cannot deploy to heroku with flask uploads
r/flask on Reddit: Cannot deploy to Heroku with Flask Uploads
July 1, 2020 -

Hi, I'm trying to deploy my flask app to heroku and it uses the package Flask-Uploads. Though it keeps saying "ImportError: cannot import name 'secure_filename' from 'werkzeug' ". I've tried to change the import but I guess heroku just gets the lastest update to the package.