AppRegistryNotReady: Apps aren't loaded yet.

Asked by Alex Njaastad

I'm attempting to run graphite-web 1.1.2 using Python 2.7 and Django 1.11.11.

I am attempting to start the server using a slightly modified manage.py script (I added the django.setup() following suggestions found online):

```
#!/usr/bin/env python
import os
import sys
import django

if __name__ == "__main__":

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

    django.setup()

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)
```

I am executing this script like this:

`python manage.py migrate --noinput`

The script appears to execute fine, but when I try to access graphite-web this error is produced:

```
[Tue Mar 13 09:47:22.702806 2018] [wsgi:error] [pid 8034:tid 140283148187520] mod_wsgi (pid=8034): Target WSGI script '/var/vcap/packages/graphite-web/conf/graphite.wsgi' cannot be loaded as Python module.
[Tue Mar 13 09:47:22.702837 2018] [wsgi:error] [pid 8034:tid 140283148187520] mod_wsgi (pid=8034): Exception occurred processing WSGI script '/var/vcap/packages/graphite-web/conf/graphite.wsgi'.
[Tue Mar 13 09:47:22.702864 2018] [wsgi:error] [pid 8034:tid 140283148187520] Traceback (most recent call last):
[Tue Mar 13 09:47:22.702884 2018] [wsgi:error] [pid 8034:tid 140283148187520] File "/var/vcap/packages/graphite-web/conf/graphite.wsgi", line 7, in <module>
[Tue Mar 13 09:47:22.702961 2018] [wsgi:error] [pid 8034:tid 140283148187520] application = django.core.handlers.wsgi.WSGIHandler()
[Tue Mar 13 09:47:22.702977 2018] [wsgi:error] [pid 8034:tid 140283148187520] File "/var/vcap/packages/django/lib/python2.7/site-packages/Django-1.11.11-py2.7.egg/django/core/handlers/wsgi.py", line 151, in __init__
[Tue Mar 13 09:47:22.703069 2018] [wsgi:error] [pid 8034:tid 140283148187520] self.load_middleware()
[Tue Mar 13 09:47:22.703086 2018] [wsgi:error] [pid 8034:tid 140283148187520] File "/var/vcap/packages/django/lib/python2.7/site-packages/Django-1.11.11-py2.7.egg/django/core/handlers/base.py", line 80, in load_middleware
[Tue Mar 13 09:47:22.703184 2018] [wsgi:error] [pid 8034:tid 140283148187520] middleware = import_string(middleware_path)
[Tue Mar 13 09:47:22.703201 2018] [wsgi:error] [pid 8034:tid 140283148187520] File "/var/vcap/packages/django/lib/python2.7/site-packages/Django-1.11.11-py2.7.egg/django/utils/module_loading.py", line 20, in import_string
[Tue Mar 13 09:47:22.703279 2018] [wsgi:error] [pid 8034:tid 140283148187520] module = import_module(module_path)
[Tue Mar 13 09:47:22.703296 2018] [wsgi:error] [pid 8034:tid 140283148187520] File "/var/vcap/packages/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Tue Mar 13 09:47:22.703346 2018] [wsgi:error] [pid 8034:tid 140283148187520] __import__(name)
[Tue Mar 13 09:47:22.703360 2018] [wsgi:error] [pid 8034:tid 140283148187520] File "/var/vcap/packages/django/lib/python2.7/site-packages/Django-1.11.11-py2.7.egg/django/contrib/auth/middleware.py", line 4, in <module>
[Tue Mar 13 09:47:22.703435 2018] [wsgi:error] [pid 8034:tid 140283148187520] from django.contrib.auth.backends import RemoteUserBackend
[Tue Mar 13 09:47:22.703450 2018] [wsgi:error] [pid 8034:tid 140283148187520] File "/var/vcap/packages/django/lib/python2.7/site-packages/Django-1.11.11-py2.7.egg/django/contrib/auth/backends.py", line 4, in <module>
[Tue Mar 13 09:47:22.703526 2018] [wsgi:error] [pid 8034:tid 140283148187520] from django.contrib.auth.models import Permission
[Tue Mar 13 09:47:22.703540 2018] [wsgi:error] [pid 8034:tid 140283148187520] File "/var/vcap/packages/django/lib/python2.7/site-packages/Django-1.11.11-py2.7.egg/django/contrib/auth/models.py", line 4, in <module>
[Tue Mar 13 09:47:22.703657 2018] [wsgi:error] [pid 8034:tid 140283148187520] from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
[Tue Mar 13 09:47:22.703672 2018] [wsgi:error] [pid 8034:tid 140283148187520] File "/var/vcap/packages/django/lib/python2.7/site-packages/Django-1.11.11-py2.7.egg/django/contrib/auth/base_user.py", line 52, in <module>
[Tue Mar 13 09:47:22.703749 2018] [wsgi:error] [pid 8034:tid 140283148187520] class AbstractBaseUser(models.Model):
[Tue Mar 13 09:47:22.703766 2018] [wsgi:error] [pid 8034:tid 140283148187520] File "/var/vcap/packages/django/lib/python2.7/site-packages/Django-1.11.11-py2.7.egg/django/db/models/base.py", line 110, in __new__
[Tue Mar 13 09:47:22.704108 2018] [wsgi:error] [pid 8034:tid 140283148187520] app_config = apps.get_containing_app_config(module)
[Tue Mar 13 09:47:22.704125 2018] [wsgi:error] [pid 8034:tid 140283148187520] File "/var/vcap/packages/django/lib/python2.7/site-packages/Django-1.11.11-py2.7.egg/django/apps/registry.py", line 247, in get_containing_app_config
[Tue Mar 13 09:47:22.704251 2018] [wsgi:error] [pid 8034:tid 140283148187520] self.check_apps_ready()
[Tue Mar 13 09:47:22.704266 2018] [wsgi:error] [pid 8034:tid 140283148187520] File "/var/vcap/packages/django/lib/python2.7/site-packages/Django-1.11.11-py2.7.egg/django/apps/registry.py", line 125, in check_apps_ready
[Tue Mar 13 09:47:22.704288 2018] [wsgi:error] [pid 8034:tid 140283148187520] raise AppRegistryNotReady("Apps aren't loaded yet.")
[Tue Mar 13 09:47:22.704308 2018] [wsgi:error] [pid 8034:tid 140283148187520] AppRegistryNotReady: Apps aren't loaded yet.
[Tue Mar 13 09:47:22.704605 2018] [wsgi:error] [pid 8038:tid 140283148187520] app_config = apps.get_containing_app_config(module)
[Tue Mar 13 09:47:22.704628 2018] [wsgi:error] [pid 8038:tid 140283148187520] File "/var/vcap/packages/django/lib/python2.7/site-packages/Django-1.11.11-py2.7.egg/django/apps/registry.py", line 247, in get_containing_app_config
[Tue Mar 13 09:47:22.704763 2018] [wsgi:error] [pid 8038:tid 140283148187520] self.check_apps_ready()
[Tue Mar 13 09:47:22.704780 2018] [wsgi:error] [pid 8038:tid 140283148187520] File "/var/vcap/packages/django/lib/python2.7/site-packages/Django-1.11.11-py2.7.egg/django/apps/registry.py", line 125, in check_apps_ready
[Tue Mar 13 09:47:22.704803 2018] [wsgi:error] [pid 8038:tid 140283148187520] raise AppRegistryNotReady("Apps aren't loaded yet.")
[Tue Mar 13 09:47:22.704824 2018] [wsgi:error] [pid 8038:tid 140283148187520] AppRegistryNotReady: Apps aren't loaded yet.
```

This may be more of a Django issue than a Graphite issue, but I'm lost as to what I should do about it.

I'm upgrading from Graphite 0.9.x and Django 1.3.x, and I used to be able to run graphite-web by running `python manage.py syncdb --noinput` on an unmodified manage.py.

Question information

Language:
English Edit question
Status:
Solved
For:
Graphite Edit question
Assignee:
No assignee Edit question
Solved by:
Alex Njaastad
Solved:
Last query:
Last reply:
Revision history for this message
Denis Zhdanov (deniszhdanov) said :
#1

Hi Alex,

Sorry, it's not really clear what's your issue is, could you please elaborate?
If unmodified manage.py works and modified is not - then do not use modified. or I'm missing something?

Revision history for this message
Alex Njaastad (anjaastad) said :
#2

At the time I posted the question I greatly misunderstood how Graphite was actually being run in a configuration I inherited. I reviewed https://graphite.readthedocs.io/en/latest/config-webapp.html and was able to solve my problems fairly quickly.