sboomi
sboomi

Reputation: 11

Flask module issue: imports a non-used Flask module

I'm starting a Flask app and I can't run it since it keeps asking for a module not present in the app.py file :

import os
from flask import Flask, render_template, request, redirect, session, url_for
from flask_dropzone import Dropzone
from flask_uploads import UploadSet, configure_uploads, IMAGES, patch_request_class

Yet when I run the app, I get the same traceback error :

from werkzeug import secure_filename, FileStorage
ImportError: cannot import name 'secure_filename' from 'werkzeug' (D:\<username>\PythonProjects\envs\plantnet_simplon\lib\site-packages\werkzeug\__init__.py)

Context: I previously launched the app with the secure_filename function, but I completley removed it afterwards. It seems the Flask server keeps an old snapshot in memory. Can someone please tell me how to start the app?

EDIT: Answer here

Upvotes: 0

Views: 176

Answers (2)

sboomi
sboomi

Reputation: 11

I actually solved the issue and it's because pip flask-uploads installed for some weird reason an defectuous version of its package.

In flask-upload.py it should be

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

Not sure why pip doesn't update tot he latest version, since it's the requirements in the file on master.

Upvotes: 0

Swathi
Swathi

Reputation: 19

from werkzeug.utils import secure_filename https://flask.palletsprojects.com/en/1.1.x/patterns/fileuploads/

Upvotes: 1

Related Questions