尝试使用Python部署Web Flask应用程序时出现WSGI错误

我想使用pythonanywhere公开部署我的flask应用程序。我是新手(我是初学者)。我完全遵循了所有步骤。但是我的Web flask应用程序出现了一些错误。在我的网站上,我使用python3.7,HTML,CSS和JavaScript。 这是错误日志上的错误消息:

2020-08-14 08:37:07,432: Error running Wsgi application
2020-08-14 08:37:07,435: ModuleNotFoundError: No module named 'pandas'
2020-08-14 08:37:07,436:   File "/var/www/analisisbipolardisorder_pythonanywhere_com_wsgi.py",line 18,in <module>
2020-08-14 08:37:07,436:     from my_flask_app import app as application  # noqa
2020-08-14 08:37:07,436: 
2020-08-14 08:37:07,436:   File "/home/analisisbipolardisorder/mysite/my_flask_app.py",line 3,436:     from pandas import DataFrame,read_csv
2020-08-14 08:37:07,437:
***************************************************
2020-08-14 08:37:07,437: If you're seeing an import error and don't kNow why,2020-08-14 08:37:07,438: we have a dedicated help page to help you debug: 
2020-08-14 08:37:07,438: https://help.pythonanywhere.com/pages/DebuggingImportError/
2020-08-14 08:37:07,439:
***************************************************

我真的不知道该如何解决。 在名为“ my_flask_app.py”的文件上,有这样的警告:

  • 已导入但未使用的“ flask.url_for”(即使我需要其他文件中的“ url_for”模块)
  • 已导入但未使用的“ pandas”(即使我需要库pandas才能导入DataFrame和read_csv模块)
  • 'pandas.DataFrame'已导入但未使用
  • 已导入但未使用的“ pandas.read_csv”

在我的Wsgi文件上,也有这样的警告:

  • “ my_flask_app.app作为应用程序”已导入但未使用(即使我需要使用它来运行我的Web flask应用程序)

我的烧瓶看起来像这样(my_flask_app.py):

from flask import Flask,render_template,url_for
import pandas
from pandas import DataFrame,read_csv
import csv

app = Flask(__name__)

@app.route('/')
def index():
    with open (r"/home/analisisbipolardisorder/css/bipolarlabelled.csv",encoding="utf8") as file:
        reader = csv.reader(file)
        dataset = [row for row in reader]
    with open (r"/home/analisisbipolardisorder/css/df_train90.csv",encoding="utf8") as train_file:
        reader = csv.reader(train_file)
        train = [row for row in reader]
    with open (r"/home/analisisbipolardisorder/css/test_prediction_9010.csv",encoding="utf8") as test_file:
        reader = csv.reader(test_file)
        test = [row for row in reader]
    return render_template('home.html',data = dataset,train = train,test = test)

if __name__ == "__main__":
    app.run(debug=True)

我的Wsgi文件如下:

# This file contains the Wsgi configuration required to serve up your
# web application at http://<your-username>.pythonanywhere.com/
# It works by setting the variable 'application' to a Wsgi handler of some
# description.
#
# The below has been auto-generated for your Flask project

import sys

# add your project directory to the sys.path
project_home = '/home/analisisbipolardisorder/mysite'
if project_home not in sys.path:
    sys.path.insert(0,project_home)

# import flask app but need to call it "application" for Wsgi to work
from my_flask_app import app as application  # noqa

我真的需要您的帮助。谢谢你。

相关文章

功能概要:(目前已实现功能)公共展示部分:1.网站首页展示...
大体上把Python中的数据类型分为如下几类: Number(数字) ...
开发之前第一步,就是构造整个的项目结构。这就好比作一幅画...
源码编译方式安装Apache首先下载Apache源码压缩包,地址为ht...
前面说完了此项目的创建及数据模型设计的过程。如果未看过,...
python中常用的写爬虫的库有urllib2、requests,对于大多数比...