Home > Back-end >  ImportError: cannot import name 'FileWrapper' from 'werkzeug'
ImportError: cannot import name 'FileWrapper' from 'werkzeug'

Time:08-04

PS C:\ProgramData\Microsoft\DeviceSync\New folder\pyRD-master> python .\app.py
Traceback (most recent call last):
  File ".\app.py", line 3, in <module>
    from werkzeug import FileWrapper
ImportError: cannot import name 'FileWrapper' from 'werkzeug' (C:\Users\scanner.PSHFAST.000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\werkzeug\__init__.py)

why does this happen? and how can I fix it.

CodePudding user response:

According to the documentation, "You should not use this class directly but rather use the wrap_file() function that uses the WSGI server’s file wrapper support if it’s available."

So your import statement (sourced from this example) should be

from werkzeug.wsgi import wrap_file
  • Related