简体   繁体   English

Python3.5 wsgi中没有模块

[英]Python3.5 no module in wsgi

i'm tring to deploy wsgi application which was build-ed using django but when i try to go to page which should serve me django page i got 500 error and in error_log i can see我正在尝试部署使用 django 构建的 wsgi 应用程序,但是当我尝试将 go 转到应该为我服务的页面 django 页面时,我可以看到 500 错误和错误日志

mod_wsgi (pid=1421): Failed to exec Python script file '/var/www/html/celery/vcs_celery/parsing_hub/parsing_hub/wsgi.py'.
mod_wsgi (pid=1421): Exception occurred processing WSGI script '/var/www/html/celery/vcs_celery/parsing_hub/parsing_hub/wsgi.py'.
Traceback (most recent call last):
File "/var/www/html/celery/vcs_celery/parsing_hub/parsing_hub/wsgi.py", line 15, in <module>
    application = get_wsgi_application()
File "/usr/lib64/python3.5/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
File "/usr/lib64/python3.5/site-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/usr/lib64/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__
    self._setup(name)
File "/usr/lib64/python3.5/site-packages/django/conf/__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
File "/usr/lib64/python3.5/site-packages/django/conf/__init__.py", line 106, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib64/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 985, in _gcd_import
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 943, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 985, in _gcd_import
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
ImportError: No module named 'parsing_hub'

I'm new to deploying python applications, any help is most appreciated我是部署 python 应用程序的新手,非常感谢任何帮助

EDIT编辑

"""
WSGI config for parsing_hub 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.0/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "parsing_hub.settings")

application = get_wsgi_application()

It looks like your Python path for finding packages and modules does not include the necessary directories.看起来您用于查找包和模块的 Python 路径不包含必要的目录。 From your traceback, you should make sure your project can be imported, by setting the PYTHONPATH environment variable.从您的回溯中,您应该确保可以通过设置 PYTHONPATH 环境变量来导入您的项目。 How to do this, depends on your environment, and whether you're running from a command line, through a webserver or otherwise.如何执行此操作取决于您的环境,以及您是从命令行、通过网络服务器还是其他方式运行。

You should set it to (or rather, add to it) the following string (directory name):您应该将其设置为(或者更确切地说,添加到其中)以下字符串(目录名称):

/var/www/html/celery/vcs_celery/parsing_hub

or, if that fails, try或者,如果失败,请尝试

/var/www/html/celery/vcs_celery

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM