I was trying to use flask-uploads module but I found in the thread:
Flask-Uploads Module
That I should go with flask-reuploaded module to fix the error:
import name 'secure_filename' from 'werkzeug' (c:\users\gabri\desktop\shop\venv\lib\site-packages\werkzeug\__init__.py)
It says in the thread that I don't have to change a line of code but I dont know how to import the module properly, because when I try
from flask_uploads import UploadSet I get
No module named 'flask_uploads'
and if I try any variation of from flask-reuploaded import UploadSet It cannot find the proper library to import
I didn't find anything about it in documentation can you please help?
The package for Flask-Uploads on PyPi is broken since February 2020 when Werkzeug changed its API, thus the error message you see.
You can either install Flask-Uploads directly from GitHub or instead of Flask-Uploads install Flask-Reuploaded which is a compatible drop-in replacement.
https://pypi.org/project/Flask-Reuploaded/
As of Oct 5th, 2020, there is no "get started" guide on Flask-Reuploadeds README page, that's correct.
As stated in the https://flask-reuploaded.readthedocs.io/en/latest/ and as you tried already, you just have to install Flask-Reuploaded and then e.g. do a from flask_uploads import Uploadset.
Please note it is from flask_uploads... not from flask_reuploaded. That is done on purpose to be 100% compatible with Flask-Uploads.
When you experience an error like No module named 'flask_uploads' this strongly indicates one of two possible problems:
Flask-ReuploadedFlaskPlease make sure to install both packages into the same virtual environment.
To prove it... do a pip freeze - for me that would look like the following...
~/Projects/example_flask_reuploaded took 10s
❯ pip freeze
click==7.1.2
Flask==1.1.2
Flask-Reuploaded==0.3.2
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
Werkzeug==1.0.1
That all said - I will update the README section of Flask-Reuploaded as soon as possible.
Update, January 18th, 2021
I have updated the README of Flask-Reuploaded with more clear information how to get a project started.
https://github.com/jugmac00/flask-reuploaded/blob/master/README.rst
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With