访问主页时出现 Pythonanywhere 错误
Posted
技术标签:
【中文标题】访问主页时出现 Pythonanywhere 错误【英文标题】:Pythonanywhere error when accessing the homepage 【发布时间】:2020-06-03 12:25:56 【问题描述】:当我访问我的主页(在 Pythonanywhere 上)时出现以下错误。我相信 WSGI 文件中的所有设置都是正确的。 ImportError: No module named 'myproject' - 即使该模块存在。这是我必须在某个地方定义的东西吗?
错误如下:
2020-02-19 02:25:26,696: Error running WSGI application
2020-02-19 02:25:26,697: ImportError: No module named 'myproject'
2020-02-19 02:25:26,697: File "/var/www/user1_pythonanywhere_com_wsgi.py", line 16, in <module>
2020-02-19 02:25:26,697: application = get_wsgi_application()
2020-02-19 02:25:26,697:
2020-02-19 02:25:26,697: File "/home/user1/.virtualenvs/mysite-virtualenv/lib/python3.5/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2020-02-19 02:25:26,697: django.setup(set_prefix=False)
2020-02-19 02:25:26,697:
2020-02-19 02:25:26,697: File "/home/user1/.virtualenvs/mysite-virtualenv/lib/python3.5/site-packages/django/__init__.py", line 19, in setup
2020-02-19 02:25:26,698: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2020-02-19 02:25:26,698:
2020-02-19 02:25:26,698: File "/home/user1/.virtualenvs/mysite-virtualenv/lib/python3.5/site-packages/django/conf/__init__.py", line 79, in __getattr__
2020-02-19 02:25:26,698: self._setup(name)
2020-02-19 02:25:26,698:
2020-02-19 02:25:26,698: File "/home//.virtualenvs/mysite-virtualenv/lib/python3.5/site-packages/django/conf/__init__.py", line 66, in _setup
2020-02-19 02:25:26,698: self._wrapped = Settings(settings_module)
2020-02-19 02:25:26,698:
2020-02-19 02:25:26,699: File "/home/user1/.virtualenvs/mysite-virtualenv/lib/python3.5/site-packages/django/conf/__init__.py", line 157, in __init__
2020-02-19 02:25:26,699: mod = importlib.import_module(self.SETTINGS_MODULE)
【问题讨论】:
【参考方案1】:在 PythonAnywhere 上,就在日志中出现异常之后,会有一个指向帮助页面的链接,引导您调试 Web 应用程序中的导入错误。
【讨论】:
【参考方案2】:我想通了。这是路径的问题。我放弃了该应用程序并从头开始重新创建它。像魅力一样工作!
【讨论】:
以上是关于访问主页时出现 Pythonanywhere 错误的主要内容,如果未能解决你的问题,请参考以下文章
PythonAnywhere:尝试使用 easygui 模块时出现 Tkinter.py 错误
将mysql与pythonanywhere一起使用时出现错误4