1

下午好,我正在开发一个 Django 应用程序并尝试使用 gunicorn 和 nginx 作为 http 的 Web 服务器负载平衡器来开发它。当尝试从 venv 中启动 gunicorn 时(该应用程序正在 venv 中开发)使用

../bin/gunicorn biblio_cfv.wsgi:应用程序

我收到这些错误

[2016-10-14 16:37:13 -0400] [22618] [INFO] Starting gunicorn 19.6.0
[2016-10-14 16:37:13 -0400] [22618] [INFO] Listening at: http://127.0.0.1:8000 (22618)
[2016-10-14 16:37:13 -0400] [22618] [INFO] Using worker: sync
[2016-10-14 16:37:13 -0400] [22621] [INFO] Booting worker with pid: 22621
[2016-10-14 20:37:22 +0000] [22621] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker
    worker.init_process()
  File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
    self.load_wsgi()
  File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/home/eddyraz/proyectos/www/VPS_WEB_DEVEL/lib/python3.5/site-packages/gunicorn/util.py", line 368, in import_app
    app = eval(obj, mod.__dict__)
  File "<string>", line 0

    ^
SyntaxError: unexpected EOF while parsing

我用 gunicorn 代码检查了文件 util.py 并没有发现任何错误

这是给出错误的代码的功能。

def import_app(module):
    parts = module.split(":", 1)
    if len(parts) == 1:
        module, obj = module, "application"
    else:
        module, obj = parts[0], parts[1]

    try:
        __import__(module)
    except ImportError:
        if module.endswith(".py") and os.path.exists(module):
            msg = "Failed to find application, did you mean '%s:%s'?"
            raise ImportError(msg % (module.rsplit(".", 1)[0], obj))
        else:
            raise

    mod = sys.modules[module]

    try:
        app = eval(obj, mod.__dict__)

    except NameError:
        raise AppImportError("Failed to find application: %r" % module)

    if app is None:
        raise AppImportError("Failed to find application object: %r" % obj)

    if not callable(app):
        raise AppImportError("Application object must be callable.")
    return app

请任何人对此有所了解。提前致谢。

4

1 回答 1

0

我知道这是很久以前问过的,但我刚刚解决了我的问题。

只需在该虚拟环境中“pip install gunicorn”

于 2022-03-05T09:32:38.807 回答