django.core.exceptions.AppRegistryNotReady:尚未加载应用。当我运行uwsgi时

时间:2018-05-10 02:31:19

标签: python uwsgi

在我的虚拟环境中,当我使用uwsgi --ini uwsgi.ini运行uWSGI时。

我收到了轰鸣声错误:

mapped 543168 bytes (530 KB) for 20 cores
*** Operational MODE: threaded ***
Traceback (most recent call last):
  File "Qiyun02/wsgi.py", line 18, in <module>
    from 管理员后台.网站管理.admin_website_chat.views import sio
  File "./管理员后台/网站管理/admin_website_chat/views.py", line 2, in <module>
    from 管理员后台.用户管理admin_usermanage.models import User
  File "./管理员后台/用户管理/admin_usermanage/models.py", line 6, in <module>
    from django.contrib.auth.models import AbstractUser
  File "/home/lll/repo/myProject/venv_dist/lib/python3.5/site-packages/django/contrib/auth/models.py", line 4, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/home/lll/repo/QmyProjectyun02/venv_dist/lib/python3.5/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
    class AbstractBaseUser(models.Model):
  File "/home/lll/repo/myProject/venv_dist/lib/python3.5/site-packages/django/db/models/base.py", line 110, in __new__
    app_config = apps.get_containing_app_config(module)
File "/home/lll/repo/myProject/venv_dist/lib/python3.5/site-packages/django/apps/registry.py", line 247, in get_containing_app_config
    self.check_apps_ready()
  File "/home/lll/repo/myProject/venv_dist/lib/python3.5/site-packages/django/apps/registry.py", line 125, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
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: 32347)
spawned uWSGI worker 1 (pid: 32349, cores: 20)
spawned uWSGI http 1 (pid: 32350)

但在我的虚拟环境中,我使用python检查,没有问题。

(venv_dist) [ldl@www myProject]$ python3 manage.py check 
System check identified no issues (0 silenced).

我也可以在我的虚拟环境中python3 manage.py runserver

为什么运行uwsgi时出现此AppRegistryNotReady错误?

或者,uwsgi是否支持非拉丁字符?我在那里有一些汉字。

2 个答案:

答案 0 :(得分:0)

Traceback (most recent call last):
  File "Qiyun02/wsgi.py", line 18, in <module>
    from 管理员后台.网站管理.admin_website_chat.views import sio
  ...

您不应从view uwsgi.py导入内容,因为django在加载uwsgi.py时尚未设置。

当您运行python3 manage.py runserver时,它与uwsgi.py无关。

答案 1 :(得分:0)

因为在使用django时没有设置,你应该在你的代码之前设置它:

import django 

django.setup() 
... # your code

希望这对你有所帮助。