【发布时间】:2022-12-03 00:26:30
【问题描述】:
我在 pythonanywhere 上托管了一个 Flask 网站,但在访问该网站时,我一直收到“未处理的异常”错误。我检查了错误日志,问题出在一个名为 finance.db 的数据库文件上。错误日志中的确切文本如下:
2022-04-26 07:23:21,225: Error running WSGI application
2022-04-26 07:23:21,239: RuntimeError: does not exist: finance.db
2022-04-26 07:23:21,240: File "/var/www/routsiddharth_pythonanywhere_com_wsgi.py", line 16, in <module>
2022-04-26 07:23:21,240: from app import app as application # noqa
2022-04-26 07:23:21,240:
2022-04-26 07:23:21,240: File "/home/routsiddharth/mysite/app.py", line 39, in <module>
2022-04-26 07:23:21,240:
2022-04-26 07:23:21,240: File "/home/routsiddharth/.local/lib/python3.9/site-packages/cs50/sql.py", line 60, in __init__
2022-04-26 07:23:21,240: raise RuntimeError("does not exist: {}".format(matches.group(1)))
2022-04-26 07:23:21,241: ***************************************************
2022-04-26 07:23:21,241: If you're seeing an import error and don't know why,
2022-04-26 07:23:21,241: we have a dedicated help page to help you debug:
2022-04-26 07:23:21,241: https://help.pythonanywhere.com/pages/DebuggingImportError/
2022-04-26 07:23:21,241: ***************************************************
这是我导入文件的方式:
from cs50 import SQL
db = SQL("sqlite:///finance.db")
finance.db 文件与 app.py 文件位于同一目录中。
我该如何解决这个错误?
【问题讨论】:
标签: python flask pythonanywhere