最开始试用的 django rest 没有问题跑了一段时间。新加了 celery 模块部署到服务器一直报下面的错误。现在使用 runserver 启动也是没问题的,使用 uwsgi 启动就会报错。
from . import sasl
ImportError: cannot import name sasl
下面是启动报错信息。
uwsgi --ini mysite_uwsgi.ini
[uWSGI] getting INI configuration from mysite_uwsgi.ini
*** Starting uWSGI 2.0.15 (64bit) on [Fri Jul 14 08:48:30 2017] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-18) on 14 July 2017 08:26:28
os: Linux-2.6.32-696.1.1.el6.x86_64 #1 SMP Tue Apr 11 17:13:24 UTC 2017
nodename: jccs_no-pt-hc-vm1
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /usr/local/tutorial
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /usr/local/tutorial
your processes number limit is 39168
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /usr/local/tutorial/tutorial/mysite.sock fd 3
Python version: 2.7.13 (default, Mar 13 2017, 10:23:38) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xa2fc70
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 800448 bytes (781 KB) for 10 cores
*** Operational MODE: preforking ***
Traceback (most recent call last):
File "/usr/local/tutorial/tutorial/
wsgi.py", line 21, in <module>
application = get_wsgi_application()
File "/usr/local/lib/python2.7/site-packages/django/core/
wsgi.py", line 13, in get_wsgi_application
django.setup(set_prefix=False)
File "/usr/local/lib/python2.7/site-packages/django/
__init__.py", line 22, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/usr/local/lib/python2.7/site-packages/django/conf/
__init__.py", line 53, in __getattr__
self._setup(name)
File "/usr/local/lib/python2.7/site-packages/django/conf/
__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/site-packages/django/conf/
__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/lib/python2.7/importlib/
__init__.py", line 37, in import_module
__import__(name)
File "/usr/local/tutorial/tutorial/
__init__.py", line 5, in <module>
from .celery import app as celery_app
File "/usr/local/tutorial/tutorial/
celery.py", line 3, in <module>
from celery import Celery
File "/usr/local/lib/python2.7/site-packages/celery/
local.py", line 509, in __getattr__
module = __import__(self._object_origins[name], None, None, [name])
File "/usr/local/lib/python2.7/site-packages/celery/app/
__init__.py", line 5, in <module>
from celery import _state
File "/usr/local/lib/python2.7/site-packages/celery/
_state.py", line 15, in <module>
from celery.utils.threads import LocalStack
File "/usr/local/lib/python2.7/site-packages/celery/utils/
__init__.py", line 10, in <module>
from .nodenames import worker_direct, nodename, nodesplit
File "/usr/local/lib/python2.7/site-packages/celery/utils/
nodenames.py", line 7, in <module>
from kombu.entity import Exchange, Queue
File "/usr/local/lib/python2.7/site-packages/kombu/
entity.py", line 6, in <module>
from .abstract import MaybeChannelBound, Object
File "/usr/local/lib/python2.7/site-packages/kombu/
abstract.py", line 6, in <module>
from .connection import maybe_channel
File "/usr/local/lib/python2.7/site-packages/kombu/
connection.py", line 15, in <module>
from kombu import exceptions
File "/usr/local/lib/python2.7/site-packages/kombu/
exceptions.py", line 6, in <module>
from amqp import ChannelError, ConnectionError, ResourceError
File "/usr/local/lib/python2.7/site-packages/amqp/
__init__.py", line 47, in <module>
from .connection import Connection # noqa
File "/usr/local/lib/python2.7/site-packages/amqp/
connection.py", line 27, in <module>
from . import sasl
ImportError: cannot import name sasl
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 14535)
spawned uWSGI worker 1 (pid: 14539, cores: 1)
spawned uWSGI worker 2 (pid: 14540, cores: 1)
spawned uWSGI worker 3 (pid: 14541, cores: 1)
spawned uWSGI worker 4 (pid: 14542, cores: 1)
spawned uWSGI worker 5 (pid: 14543, cores: 1)
spawned uWSGI worker 6 (pid: 14544, cores: 1)
spawned uWSGI worker 7 (pid: 14545, cores: 1)
spawned uWSGI worker 8 (pid: 14546, cores: 1)
spawned uWSGI worker 9 (pid: 14547, cores: 1)
spawned uWSGI worker 10 (pid: 14548, cores: 1)
^CSIGINT/SIGQUIT received...killing workers...
worker 1 buried after 1 seconds
worker 2 buried after 1 seconds
worker 3 buried after 1 seconds
worker 4 buried after 1 seconds
worker 5 buried after 1 seconds
worker 6 buried after 1 seconds
worker 7 buried after 1 seconds
worker 8 buried after 1 seconds
worker 9 buried after 1 seconds
worker 10 buried after 1 seconds
goodbye to uWSGI.