Gunicorn导入错误

时间:2016-01-26 22:58:38

标签: python flask gunicorn

我正试图让一个烧瓶应用程序与gunicorn一起工作。

当我执行以下操作时,它可以工作:

. env/bin/activate
python app.py

然而,当我这样做时:

. env/bin/activate
gunicorn app:app -b localhost:8005

它无法正常工作,引用了导入simplejson的问题。 simplejson安装在virtualenv和std python lib

好的,玩完之后,这简直就是引起了大惊小怪。删除导入允许系统运行。然而,simplejson是一个关键因素。

[2016-01-26 22:53:32 +0000] [22522] [INFO] Starting gunicorn 19.3.0
[2016-01-26 22:53:32 +0000] [22522] [INFO] Listening at: http://127.0.0.1:8005 (22522)
[2016-01-26 22:53:32 +0000] [22522] [INFO] Using worker: sync
[2016-01-26 22:53:32 +0000] [22527] [INFO] Booting worker with pid: 22527
[2016-01-26 22:53:32 +0000] [22527] [ERROR] Exception in worker process:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 507, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 118, in init_process
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 355, in import_app
    __import__(module)
  File "/home/flasker/killerfees/app.py", line 1, in <module>
    from kf import app
  File "/home/flasker/killerfees/kf/__init__.py", line 21, in <module>
    from kf import views
  File "/home/flasker/killerfees/kf/views.py", line 4, in <module>
    import simplejson
ImportError: No module named simplejson
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 507, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 118, in init_process
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 355, in import_app
    __import__(module)
  File "/home/flasker/killerfees/app.py", line 1, in <module>
    from kf import app
  File "/home/flasker/killerfees/kf/__init__.py", line 21, in <module>
    from kf import views
  File "/home/flasker/killerfees/kf/views.py", line 4, in <module>
    import simplejson
ImportError: No module named simplejson
[2016-01-26 22:53:32 +0000] [22527] [INFO] Worker exiting (pid: 22527)
[2016-01-26 22:53:32 +0000] [22522] [INFO] Shutting down: Master
[2016-01-26 22:53:32 +0000] [22522] [INFO] Reason: Worker failed to boot.

sys.path中:

['/home/flasker/killerfees', '/usr/local/bin', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/local/lib/python2.7/dist-packages/newrelic-2.50.0.39', '/usr/lib/python2.7/dist-packages']

从views.py导入:

from kf import app, mail, model, va, pdfgen
from flask import render_template, request, session, redirect, url_for, jsonify, make_response, g, flash, abort
from flask.ext.mail import Message
import simplejson

0 个答案:

没有答案