[英]Error running WSGI application, within pythonanywhere
Good day to all,祝大家有个美好的一天,
I was having some issues trying to host my django webapp within pythonanywhere and I keep getting the following errors within the server.我在尝试在 pythonanywhere 中托管我的 django webapp 时遇到了一些问题,我在服务器中不断收到以下错误。 Sorry in advance I'm a beginner when it comes to programming
提前抱歉,我是编程的初学者
WSGI File: WSGI 文件:
# +++++++++++ DJANGO +++++++++++
# To use your own Django app use code like this:
import os
import sys
# assuming your Django settings file is at '/home/myusername/mysite/mysite/settings.py'
path = '/home/HumBen/AMC_Inventory/venv/src/src/settings.py'
if path not in sys.path:
sys.path.insert(0, path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'src.settings'
## Uncomment the lines below depending on your Django version
###### then, for Django >=1.5:
from django.core.wsgi import get_wsgi_application
stockmgmt = get_wsgi_application()
###### or, for older Django <=1.4
#import django.core.handlers.wsgi
#application = django.core.handlers.wsgi.WSGIHandler()
Server error:服务器错误:
2021-10-27 22:59:31,228: Error running WSGI application
2021-10-27 22:59:31,233: ModuleNotFoundError: No module named 'src'
2021-10-27 22:59:31,233: File "/var/www/humben_pythonanywhere_com_wsgi.py", line 16, in <module>
2021-10-27 22:59:31,233: application = get_wsgi_application()
2021-10-27 22:59:31,233:
2021-10-27 22:59:31,233: File "/home/HumBen/AMC_Inventory/venv/lib/python3.9/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2021-10-27 22:59:31,233: django.setup(set_prefix=False)
2021-10-27 22:59:31,233:
2021-10-27 22:59:31,233: File "/home/HumBen/AMC_Inventory/venv/lib/python3.9/site-packages/django/__init__.py", line 19, in setup
2021-10-27 22:59:31,234: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2021-10-27 22:59:31,234:
2021-10-27 22:59:31,234: File "/home/HumBen/AMC_Inventory/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__
2021-10-27 22:59:31,234: self._setup(name)
2021-10-27 22:59:31,234:
2021-10-27 22:59:31,234: File "/home/HumBen/AMC_Inventory/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 69, in _setup
2021-10-27 22:59:31,235: self._wrapped = Settings(settings_module)
2021-10-27 22:59:31,235:
2021-10-27 22:59:31,235: File "/home/HumBen/AMC_Inventory/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 170, in __init__
2021-10-27 22:59:31,235: mod = importlib.import_module(self.SETTINGS_MODULE)
2021-10-27 22:59:31,235: ***************************************************
Thank you all in advance, blessings to all!先谢谢大家了,祝福大家!
Assuming that manage.py
is in /home/HumBen/AMC_Inventory/venv/src
, you should add this path to PYTHONPATH
(here: via sys.path.insert
call).假设
manage.py
在/home/HumBen/AMC_Inventory/venv/src
,您应该将此路径添加到PYTHONPATH
(此处:通过sys.path.insert
调用)。 Then, assuming that settings.py
is in /home/HumBen/AMC_Inventory/venv/src/src
your current DJANOG_SETTINGS_MODULE
config should work.然后,假设
settings.py
在/home/HumBen/AMC_Inventory/venv/src/src
您当前的DJANOG_SETTINGS_MODULE
配置应该可以工作。 You need to change stockmgmt
to application
, as well.您还需要将
stockmgmt
更改为application
。 Also -- remember to edit the wsgi file that is linked to in your Web page on PythonAnywhere and reload the web app.另外 -- 请记住在 PythonAnywhere 上编辑链接到您的网页中的 wsgi 文件并重新加载 Web 应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.