I have a flask app that was working fine for years. But I just got this error today:
Error running WSGI application
ImportError: No module named flask
File "/var/www/[user]_pythonanywhere_com_wsgi.py", line 16, in <module>
from flask_app import app as application
File "/home/[user]/mysite/flask_app.py", line 1, in <module>
from flask import Flask,redirect
How should I fix this?
I have exactly the same problem. Do you have a fix?
On 27 October, your account was updated from our old "classic" system image, which has various Python packages installed for Python 2.7 and 3.5, to our newer "glastonbury" image, which doesn't have those pre-installed packages. If you run
pip3.5install--userflask
...in a bash console (assuming that you're using Python 3.5 -- change the numbers if you're using a different Python version) then that will fix this issue.
BTW, for clarity -- over the last year, we've been sending emails to the owners of all accounts that were going to be affected by this change so that people would have a chance to make any required changes up-front and avoid any downtime.
I did a pip install for flask when I first had that error. I just ran it again to double check. It seems that flask is already installed. The message is below. Is the code in mysite running through a different python version?
stdout.txt (in my home directory) does have "Python 3.9.5". The only thing I can think of is the app is running "somewhere else" with python 3.9, but without flask installed? But then I have also done a "pwd" in the flask app and redirect just like the above and "pwd" says I'm in my home directory.
Sorry, we have had to rate-limit your feedback sending. Please try again in a few moments...
Thanks for the feedback! Our tireless devs will get back to you soon.