ModuleNotFoundError:没有名为'test_proj.settings'的模块

问题描述 投票:0回答:1

我正在尝试在cPanel 78.0.45上部署django应用。参见Setup Python App Configuration heredjangoapp是应用程序根目录。 djangoapp目录的结构如下:

__pycache__/
     passenger_wsgi.cpython-37.pyc
log
passenger_wsgi.py
public
tmp
test_proj/                 /*the name of django app*/
     test_proj/
          __init__.py
          __pycache__
          settings.py
          urls.py
          wsgi.py
     manage.py

passenger_wsgi.py]的脚本是:

import imp
import os
import sys


sys.path.insert(0, os.path.dirname(__file__))

wsgi = imp.load_source('wsgi', 'test_proj/test_proj/wsgi.py')
application = wsgi.application

wsgi.py

的脚本是:
"""
WSGI config for test_proj project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
"""
import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_proj.settings')

application = get_wsgi_application()

manage.py

的脚本是:
#!/usr/bin/env python
import os
import sys

if __name__ == '__main__':
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_proj.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)

现在的问题是,当我点击应用程序URL时,它显示为this。我检查了日志以跟踪问题,它引发了以下异常:

App 36033 output: ModuleNotFoundError
App 36033 output: : No module named 'test_proj.settings'

由于testsproj

包中存在settings.py,所以我无法弄清楚为什么会引发此异常。

我正在尝试在cPanel 78.0.45上部署django应用。请参阅此处的设置Python应用程序配置。 djangoapp是应用程序的根目录。 djangoapp目录的结构如下:__pycache __ / ...

python django deployment cpanel wsgi
1个回答
0
投票
  • 我不知道这是最好的方法,但是它解决了我的问题
© www.soinside.com 2019 - 2024. All rights reserved.