Home > OS >  Python Flask (deployed on Heroku): ImportError: cannot import name 'secure_filename' from
Python Flask (deployed on Heroku): ImportError: cannot import name 'secure_filename' from

Time:12-22

When deploying a flask application on heroku im getting the error above. The problem on heroku is that it installs dependencies and Iam not able to overwrite them then, or? On my local server i just went to flask_uploads.py and change the imports to:

from werkzeug.utils import secure_filename
from werkzeug.datastructures import  FileStorage

and this works fine.

but when deploying the flask app to heroku, how can I change the the content of flask_uploads.py after it had been installed?

CodePudding user response:

flask-uploads is no longer properly maintained and has not released a fix to the updated Werkzeug API change, thus you see this error.

Just swap flask-uploads with flask-reuoloaded in your dependency list, eg requirements.txt or similar. You don't have to change your imports!

See https://github.com/jugmac00/flask-reuploaded

  • Related