您好,我正试图在Pythonywhere中运行我的django应用程序,我遇到了这个错误。有没有人遇到过类似的问题?

2022-12-01 04:46:58 发布

您现在位置:Python中文网/ 问答频道 /正文

错误日志

2020-04-07 09:50:50,115: ***************************************************
2020-04-07 09:50:50,115: If you're seeing an import error and don't know why,
2020-04-07 09:50:50,115: we have a dedicated help page to help you debug: 
2020-04-07 09:50:50,115: https://help.pythonanywhere.com/pages/DebuggingImportError/
2020-04-07 09:50:50,115: ***************************************************
2020-04-07 09:50:53,872: Error running WSGI application
2020-04-07 09:50:53,873: ModuleNotFoundError: No module named 'psych_test_demo'
2020-04-07 09:50:53,873:   File "/var/www/evaldasmencinskas_pythonanywhere_com_wsgi.py", line 14, in <module>
2020-04-07 09:50:53,873:     application = get_wsgi_application()
2020-04-07 09:50:53,873: 
2020-04-07 09:50:53,874:   File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2020-04-07 09:50:53,874:     django.setup(set_prefix=False)
2020-04-07 09:50:53,874: 
2020-04-07 09:50:53,874:   File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/__init__.py", line 19, in setup
2020-04-07 09:50:53,874:     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2020-04-07 09:50:53,874: 
2020-04-07 09:50:53,875:   File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/conf/__init__.py", line 76, in __getattr__
2020-04-07 09:50:53,875:     self._setup(name)
2020-04-07 09:50:53,875: 
2020-04-07 09:50:53,875:   File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/conf/__init__.py", line 63, in _setup
2020-04-07 09:50:53,875:     self._wrapped = Settings(settings_module)
2020-04-07 09:50:53,875: 
2020-04-07 09:50:53,875:   File "/home/evaldasmencinskas/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/conf/__init__.py", line 142, in __init__
2020-04-07 09:50:53,875:     mod = importlib.import_module(self.SETTINGS_MODULE)
2020-04-07 09:50:53,875: ***************************************************
2020-04-07 09:50:53,875: If you're seeing an import error and don't know why,
2020-04-07 09:50:53,875: we have a dedicated help page to help you debug: 
2020-04-07 09:50:53,876: https://help.pythonanywhere.com/pages/DebuggingImportError/
2020-04-07 09:50:53,876: ***************************************************

我试着为virtualenv使用不同的名称,比如mysite virtualenv和psych_test_demo-master 我安装了应用程序运行所需的一切,就像django和xlsxwriter一样 这就是我的wsgi.py文件的样子。我在这里得到了python 3.8

import os
import sys

# assuming your Django settings file is at '/home/myusername/mysite/mysite/settings.py'
path = '/home/evaldasmencinskas/psych_test_demo-master/psych_test_demo'
if path not in sys.path:
    sys.path.insert(0, path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'psych_test_demo.settings'


from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

这是我第一次尝试在服务器上运行应用程序,所以我可能会犯一些愚蠢的错误,所以一切都是可能的。谢谢你们抽出时间


1条回答
网友
1楼 · 发布于 2022-12-01 04:46:58

wsgi.py文件中,路径variable应该与BASE_DIR(外部项目目录)的路径相同

path =   "/home/evaldasmencinskas/psych_test_demo-master"  # ( Path to your outer project directory )

热门问题