问题
A piece of code that worked fine in the past now throws the error
ModuleNotFoundError: No module named 'werkzeug.wrappers.json'; 'werkzeug.wrappers' is not a package
whenever I issue the command
from flask import Flask
while developing and debugging.
This even happens in the Flask __init__.py
script if I run it in either the Spyder or VSCode debuggers.
Weirdly my Flask application still runs when I flask run
from the console (Anaconda) and navigate my website.
The working directories all look OK, and I never had this problem before, I can't debug anymore.
I don't know if this is relevant but I uninstalled flask-bootstrap last week, and I notice that when I now try to upgrade flask with pip or conda I get error message ImportError: cannot import name 'PackageFinder' from 'pip._internal.index'
.
Can anyone suggest anything.
MORE DETAILS
I am running a typical Flask application. Here is the console when I start my app, I can go to localhost:5000
and it works.
This console is running an __init__()
function that loads up Flask and other dependencies, this script starts like so.
When I go to either the Spyder or VSCode debugger and run the same __init__()
script I immediately get the error in the title, this.
It fails on the from flask import...
statement trying to load werkzeug packages, Flask is built on jinja2 and werkzeug.
This all worked fine before, the only thing I have done is pip uninstall flask-bootstrap, and bootstrap is showing in error messages whenever I now use pip.
回答1:
Try uninstalling Flask by running pip uninstall Flask
and then installing it again by running pip install Flask --no-cache-dir
Also, the command to upgrade an existing package is pip install -U <package_name>
or pip install --upgrade <package_name>
来源:https://stackoverflow.com/questions/60478929/debuggers-throwing-modulenotfounderror-no-module-named-werkzeug-wrappers-json