无法将 Django web 托管到 PythonAnywhere
Couldnt host Django web to PythonAnywhere
我将我的 django 网站上传到 pythonanywhere,但每次我 运行 网站都会显示 Error running WSGI application, ModuleNotFoundError: No module named 'AlertTraceWebsite'
。我想我在 pythonanywhere 上错误地设置了目录,但不知道我做错了哪些步骤。任何帮助将不胜感激。谢谢。
我有一个这样的URL(项目可以找到here):
我这样配置我的 pythonanywhere url:
我的pythonanywhere wsgi:
import os
import sys
path = os.path.expanduser('~/kabiboy/atportal')
if path not in sys.path:
sys.path. insert(0, path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'AlertTraceWebsite.settings'
from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler (get_wsgi_application())
错误:
2021-10-09 07:27:34,383: Error running WSGI application
2021-10-09 07:27:34,384: ModuleNotFoundError: No module named 'AlertTraceWebsite'
2021-10-09 07:27:34,384: File "/var/www/kabiboy_pythonanywhere_com_wsgi.py", line 10, in <module>
2021-10-09 07:27:34,384: application = StaticFilesHandler (get_wsgi_application())
2021-10-09 07:27:34,384:
2021-10-09 07:27:34,385: File "/home/kabiboy/.virtualenvs/venv/lib/python3.9/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2021-10-09 07:27:34,385: django.setup(set_prefix=False)
2021-10-09 07:27:34,385:
2021-10-09 07:27:34,385: File "/home/kabiboy/.virtualenvs/venv/lib/python3.9/site-packages/django/__init__.py", line 19, in setup
2021-10-09 07:27:34,385: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2021-10-09 07:27:34,385:
2021-10-09 07:27:34,385: File "/home/kabiboy/.virtualenvs/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__
2021-10-09 07:27:34,385: self._setup(name)
2021-10-09 07:27:34,385:
2021-10-09 07:27:34,385: File "/home/kabiboy/.virtualenvs/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 69, in _setup
2021-10-09 07:27:34,386: self._wrapped = Settings(settings_module)
2021-10-09 07:27:34,386:
2021-10-09 07:27:34,386: File "/home/kabiboy/.virtualenvs/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 170, in __init__
2021-10-09 07:27:34,386: mod = importlib.import_module(self.SETTINGS_MODULE)
2021-10-09 07:27:34,386: ***************************************************
2021-10-09 07:27:34,386: If you're seeing an import error and don't know why,
2021-10-09 07:27:34,386: we have a dedicated help page to help you debug:
2021-10-09 07:27:34,386: https://help.pythonanywhere.com/pages/DebuggingImportError/
2021-10-09 07:27:34,387: ***************************************************
尝试改变你的路径
path = os.path.expanduser('~/kabiboy/atportal')
至此
path = os.path.expanduser('~/kabiboy/atportal/AlertTraceWebsite')
os.path.expanduser('~/kabiboy/atportal')
将扩展为 /home/kabiboy/kabiboy/atportal
(注意双倍的 kabiboy
部分)——这可能不是您想要的。如果你想使用 expanduser
和代字号,你应该“隐藏” /home/kabiboy
部分在代字号下。
我将我的 django 网站上传到 pythonanywhere,但每次我 运行 网站都会显示 Error running WSGI application, ModuleNotFoundError: No module named 'AlertTraceWebsite'
。我想我在 pythonanywhere 上错误地设置了目录,但不知道我做错了哪些步骤。任何帮助将不胜感激。谢谢。
我有一个这样的URL(项目可以找到here):
我这样配置我的 pythonanywhere url:
我的pythonanywhere wsgi:
import os
import sys
path = os.path.expanduser('~/kabiboy/atportal')
if path not in sys.path:
sys.path. insert(0, path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'AlertTraceWebsite.settings'
from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler (get_wsgi_application())
错误:
2021-10-09 07:27:34,383: Error running WSGI application
2021-10-09 07:27:34,384: ModuleNotFoundError: No module named 'AlertTraceWebsite'
2021-10-09 07:27:34,384: File "/var/www/kabiboy_pythonanywhere_com_wsgi.py", line 10, in <module>
2021-10-09 07:27:34,384: application = StaticFilesHandler (get_wsgi_application())
2021-10-09 07:27:34,384:
2021-10-09 07:27:34,385: File "/home/kabiboy/.virtualenvs/venv/lib/python3.9/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2021-10-09 07:27:34,385: django.setup(set_prefix=False)
2021-10-09 07:27:34,385:
2021-10-09 07:27:34,385: File "/home/kabiboy/.virtualenvs/venv/lib/python3.9/site-packages/django/__init__.py", line 19, in setup
2021-10-09 07:27:34,385: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2021-10-09 07:27:34,385:
2021-10-09 07:27:34,385: File "/home/kabiboy/.virtualenvs/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__
2021-10-09 07:27:34,385: self._setup(name)
2021-10-09 07:27:34,385:
2021-10-09 07:27:34,385: File "/home/kabiboy/.virtualenvs/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 69, in _setup
2021-10-09 07:27:34,386: self._wrapped = Settings(settings_module)
2021-10-09 07:27:34,386:
2021-10-09 07:27:34,386: File "/home/kabiboy/.virtualenvs/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 170, in __init__
2021-10-09 07:27:34,386: mod = importlib.import_module(self.SETTINGS_MODULE)
2021-10-09 07:27:34,386: ***************************************************
2021-10-09 07:27:34,386: If you're seeing an import error and don't know why,
2021-10-09 07:27:34,386: we have a dedicated help page to help you debug:
2021-10-09 07:27:34,386: https://help.pythonanywhere.com/pages/DebuggingImportError/
2021-10-09 07:27:34,387: ***************************************************
尝试改变你的路径
path = os.path.expanduser('~/kabiboy/atportal')
至此
path = os.path.expanduser('~/kabiboy/atportal/AlertTraceWebsite')
os.path.expanduser('~/kabiboy/atportal')
将扩展为 /home/kabiboy/kabiboy/atportal
(注意双倍的 kabiboy
部分)——这可能不是您想要的。如果你想使用 expanduser
和代字号,你应该“隐藏” /home/kabiboy
部分在代字号下。