I want to deploy my flask app publicly using pythonanywhere. I am new to this (I am a beginner). I have followed all steps exactly. But I have got some error on my web flask app. On my website, I use python3.7, HTML, CSS, and JavaScript. Here's the error message on error log:
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, in <module>
2020-08-14 08:37:07,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:
***************************************************
I really don't know how to fix that. On my file named 'my_flask_app.py', there are some warning like this:
- 'flask.url_for' imported but unused (even though I need 'url_for' module in other file)
- 'pandas' imported but unused (even though I need library pandas to import DataFrame and read_csv module)
- 'pandas.DataFrame' imported but unused
- 'pandas.read_csv' imported but unused
And also on my WSGI file, there is a warning like this:
- 'my_flask_app.app as application' imported but unused (even though I need this to run my web flask app)
My Flask look like this (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)
And my WSGI file look like this:
# 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
I really need your kind of help. Thanks before.