2016-07-26 175 views
1

我有一個Django(版本1.9)應用程序與Python 2.7.10運行,我使用Virtualenv。 運行與./manage.py runserver我沒有錯誤的應用程序,但是當我嘗試在調試運行我得到django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.django.core.exceptions.AppRegistryNotReady:應用程序尚未加載尚未啓動調試pycharm

這是pycharm調試配置:

enter image description here 任何想法,爲什麼? 這裏完整的堆棧跟蹤:

/Users/matteobetti/Progetti/Enydros/enysoft/bin/python ./manage.py runserver 
    Traceback (most recent call last): 
     File "./manage.py", line 10, in <module> 
     execute_from_command_line(sys.argv) 
     File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line 
     utility.execute() 
     File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute 
     self.fetch_command(subcommand).run_from_argv(self.argv) 
     File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/core/management/__init__.py", line 176, in fetch_command 
     commands = get_commands() 
     File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/utils/lru_cache.py", line 100, in wrapper 
     result = user_function(*args, **kwds) 
     File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/core/management/__init__.py", line 71, in get_commands 
     for app_config in reversed(list(apps.get_app_configs())): 
     File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs 
     self.check_apps_ready() 
     File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready 
     raise AppRegistryNotReady("Apps aren't loaded yet.") 
    django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. 

我添加import djangoËdjango.setupexecute_from_command_line(sys.argvs)

和我得到這個堆棧跟蹤:

Traceback (most recent call last): 
    File "/Users/matteobetti/Progetti/Enydros/enysoft/manage.py", line 10, in <module> 
    django.setup() 
    File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/__init__.py", line 18, in setup 
    apps.populate(settings.INSTALLED_APPS) 
    File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate 
    app_config = AppConfig.create(entry) 
    File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/apps/config.py", line 90, in create 
    module = import_module(entry) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
    File "/Users/matteobetti/Progetti/Enydros/enysoft/frontend/apps.py", line 2, in <module> 
    from frontend.services.container import app_context 
    File "/Users/matteobetti/Progetti/Enydros/enysoft/frontend/services/container.py", line 1, in <module> 
    from frontend.services.enysoft_services import RService, FixedSizeDirectoryCache, TubeSectionService, CsvSanifier 
    File "/Users/matteobetti/Progetti/Enydros/enysoft/frontend/services/enysoft_services.py", line 5, in <module> 
    import rpy2.robjects as ro 
    File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/rpy2/robjects/__init__.py", line 15, in <module> 
    import rpy2.rinterface as rinterface 
    File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/rpy2/rinterface/__init__.py", line 16, in <module> 
    tmp = subprocess.check_output(("R", "RHOME"), universal_newlines=True) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 566, in check_output 
    process = Popen(stdout=PIPE, *popenargs, **kwargs) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__ 
    errread, errwrite) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child 
    raise child_exception 
OSError: [Errno 2] No such file or directory 

另一種東西,說的是,我與Linux collegue沒有問題使用相同的virtualenv配置,唯一有問題的是i,使用mac os。

+0

您使用的是社區版嗎? – Compadre

+0

是的。在Mac OS上的pycharm 2016.1.3 – Matt3o

回答

1

嘗試將設置文件添加到系統PATH。在我的項目中,設置位於文件夾/project_name/project_name/settings/development.py(與標準方式略有不同)。在我的情況下,環境現狀變量字符串

DJANGO_SETTINGS_MODULE=project_name.settings.development;PYTHONUNBUFFERED=1

所以要根據您的參數進行修改,然後嘗試再次運行服務器。我希望這有幫助。

+0

我不明白,我的項目中沒有任何development.py文件。設置位於/project_name/project_name/settings.py中。我應該添加什麼文件? – Matt3o

+0

比在你的情況下行將是'DJANGO_SETTINGS_MODULE = project_name.settings; PYTHONUNBUFFERED = 1' – Compadre

+0

我添加DJANGO_SETTINGS_MODULE = project_name.settings; PYTHONUNBUFFERED = 1,在字段Envinronment變量在pychharm運行/調試配置,但我得到了相同的錯誤。 – Matt3o

相關問題