添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
安静的莲藕  ·  第 2 章:Hello, Flask! - ...·  1 周前    · 
玩足球的可乐  ·  API — ...·  2 周前    · 
迷茫的海龟  ·  MySQL :: Python ...·  2 周前    · 
烦恼的四季豆  ·  Android12?-eolink官网·  2 月前    · 
大鼻子的弓箭  ·  `flutter doctor ...·  2 月前    · 
跑龙套的毛豆  ·  Cosmetology·  1 年前    · 

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?

2022-10-29 00:55:42,668: Error running WSGI application
2022-10-29 00:55:42,672: ModuleNotFoundError: No module named 'flask_cors'
2022-10-29 00:55:42,672:   File "/var/www/vinasia_pythonanywhere_com_wsgi.py", line 16, in <module>
2022-10-29 00:55:42,672:     from flask_app import app as application
2022-10-29 00:55:42,672: 
2022-10-29 00:55:42,672:   File "/home/vinasia/mysite/flask_app/__init__.py", line 5, in <module>
2022-10-29 00:55:42,672:     from flask_cors import CORS
              

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.5 install --user flask

...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?

16:47 ~ $ 
16:47 ~ $ python --version
Python 3.9.5
16:47 ~ $ pip3.9 install --user flask
Looking in links: /usr/share/pip-wheels
Requirement already satisfied: flask in /usr/local/lib/python3.9/site-packages (2.0.0)
Requirement already satisfied: itsdangerous>=2.0 in /usr/local/lib/python3.9/site-packages (from flask) (2.0.1)
Requirement already satisfied: click>=7.1.2 in /usr/local/lib/python3.9/site-packages (from flask) (7.1.2)
Requirement already satisfied: Jinja2>=3.0 in /usr/local/lib/python3.9/site-packages (from flask) (3.0.1)
Requirement already satisfied: Werkzeug>=2.0 in /usr/local/lib/python3.9/site-packages (from flask) (2.0.1)
Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.9/site-packages (from Jinja2>=3.0->flask)

(2.0.1)

I have already checked that. I tested it by adding the following to the top of flask_.app.py before the import that causes the error:

import os
os.system('python --version > stdout.txt')

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.