So I'm new to PythonAnywhere but I've got some coding experience with python, html, css etc. I designed my website using Python and I uploaded it to here but I can't get it to run. Here's what I've done since starting:
- I uploaded my project files from VS Code.
-
I uploaded my virtual env files to my virtual env on Python Anywhere. Picture below shows my file structure.
-
I then uploaded my virtual env packages from VS Code into my virtual env folder. I basically mirrored my VS Code setup.
- I then completed the dashboard page file paths as well as I could understand them.
- I then tried to run the app and got an "error, something went wrong"
The error I'm getting from the log is:
2025-05-06 13:23:33,928: Error running WSGI application
2025-05-06 13:23:33,939: ModuleNotFoundError: No module named 'flask'
2025-05-06 13:23:33,939: File "/var/www/way2go_pythonanywhere_com_wsgi.py", line 16, in <module>
2025-05-06 13:23:33,939: from myproject import app # noqa
2025-05-06 13:23:33,939: ^^^^^^^^^^^^^^^^^^^^^^^^^
2025-05-06 13:23:33,939:
2025-05-06 13:23:33,940: File "/home/way2go/myproject/__init__.py", line 2, in <module>
2025-05-06 13:23:33,940: from flask import Flask
2025-05-06 13:23:33,940: ***************************************************
2025-05-06 13:23:33,940: If you're seeing an import error and don't know why,
2025-05-06 13:23:33,941: we have a dedicated help page to help you debug:
2025-05-06 13:23:33,941: https://help.pythonanywhere.com/pages/DebuggingImportError/
2025-05-06 13:23:33,941: ***************************************************
My WSGI file is as follows:
# 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/way2go/myproject'
if project_home not in sys.path:
sys.path = [project_home] + sys.path
# import flask app but need to call it "application" for WSGI to work
from myproject import app # noqa
application = create_app()
I've scoured the forums to try and find something similar so I could try to fix it myself, but I'm not at the point where I'm not clever enough to understand quite what the error log is telling me to fix.
I am convinced it's either because I've not uploaded my files correctly and therefore something is wrong with the file structure and path pointing. Or I think it's due to my file code not calling for the correct packages from the correct places (sort of similar to the first point). Or there is something wrong with my virtual env setup.
Help would be gratefully received. :)