close

[Solved] flask_uploads: ImportError: cannot import name ‘secure_filename’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error lask_uploads: ImportError: cannot import name ‘secure_filename’ in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How lask_uploads: ImportError: cannot import name ‘secure_filename’ Error Occurs?

Today I get the following error lask_uploads: ImportError: cannot import name ‘secure_filename’ in Python.

How To Solve lask_uploads: ImportError: cannot import name ‘secure_filename’ Error ?

  1. How To Solve lask_uploads: ImportError: cannot import name 'secure_filename' Error ?

    To Solve lask_uploads: ImportError: cannot import name 'secure_filename' Error from werkzeug import secure_filename,FileStorage from werkzeug.utils import secure_filename
    from werkzeug.datastructures import FileStorage

Solution 1

In flask_uploads.py

Change

from werkzeug import secure_filename,FileStorage

to

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

Solution 2

According to this issue, it is a bug related to the current version 1.0.0 of workzeug. It’s merged but not yet published in pypi. The workaround know until now is to downgrade from werkzeug=1.0.0 to werkzeug==0.16.0

So for do that you just need run the command:

pip install -U Werkzeug==0.16.0

Looking in the release notes from werkzeug there is a version 0.16.1, but in bug report there is no evidence that using that version could be of any help.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment