无法在 pythonanywhere 站点中 运行 python 脚本

Unable to run the python script in pythonanywhere site

文件结构

__pycache__/    
 data/  
 pages/
    index.py
    __init__.py
    page_1.py
 run.py

run.py

中的代码
import pages.index as index

if __name__ == '__main__':
    index.app.run_server(debug=True)

/var/www/test_pythonanywhere_com_wsgi.py

中的代码
# 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/test/mysite/'
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 weber_dashboard import run
application = run.server

错误日志

2022-04-29 15:07:21,843: Error running WSGI application
2022-04-29 15:07:21,846: ModuleNotFoundError: No module named 'pages'
2022-04-29 15:07:21,847:   File "/var/www/test_pythonanywhere_com_wsgi.py", line 16, in <module>
2022-04-29 15:07:21,847:     from weber_dashboard import run
2022-04-29 15:07:21,847: 
2022-04-29 15:07:21,847:   File "/home/lataigmbh/mysite/weber_dashboard/run.py", line 1, in <module>
2022-04-29 15:07:21,847:     import pages.index as index
2022-04-29 15:07:21,847: ***************************************************
2022-04-29 15:07:21,848: If you're seeing an import error and don't know why,
2022-04-29 15:07:21,848: we have a dedicated help page to help you debug: 
2022-04-29 15:07:21,848: https://help.pythonanywhere.com/pages/DebuggingImportError/
2022-04-29 15:07:21,848: ***************************************************

run.py 脚本 运行 在 bash 控制台

中完美无缺

通过在所有页面上添加以下行并直接调用模块解决了问题。

import sys
sys.path.append('/.../application/app/folder')

import file_1