我已經開始通過使用Django和GraphQL進行基本設置的graphene_django tutorial。如何通過教程解決使用石墨烯django基本設置的ImportError?
但是,我無法進展的更多由於導入錯誤:
ImportError at /graphql
Could not import 'cookbook.schema.schema' for Graphene setting 'SCHEMA'. ImportError: No module named schema.
Request Method: GET
Request URL: http://127.0.0.1:8000/graphql
Django Version: 1.11.2
Exception Type: ImportError
Exception Value:
Could not import 'cookbook.schema.schema' for Graphene setting 'SCHEMA'. ImportError: No module named schema.
Exception Location: /home/mackie/Code/graphene_django_tutorial/env/local/lib/python2.7/site-packages/graphene_django/settings.py in import_from_string, line 78
Python Executable: /home/mackie/Code/graphene_django_tutorial/env/bin/python
Python Version: 2.7.12
Python Path:
['/home/mackie/Code/graphene_django_tutorial/cookbook',
'/home/mackie/Code/graphene_django_tutorial/env/lib/python2.7',
'/home/mackie/Code/graphene_django_tutorial/env/lib/python2.7/plat-x86_64-linux-gnu',
'/home/mackie/Code/graphene_django_tutorial/env/lib/python2.7/lib-tk',
'/home/mackie/Code/graphene_django_tutorial/env/lib/python2.7/lib-old',
'/home/mackie/Code/graphene_django_tutorial/env/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/home/mackie/Code/graphene_django_tutorial/env/local/lib/python2.7/site-packages',
'/home/mackie/Code/graphene_django_tutorial/env/lib/python2.7/site-packages']
Server time: Sun, 4 Jun 2017 16:29:46 +0000
你可以看到在最低迴購代碼here的當前狀態。
我認爲我的問題與我如何運行服務器有關:python3 manage.py runserver
。或者,也許我是如何進口的。但我不知道如何從這裏做更多的調試。
一切都完全如教程中所述,沒有什麼似乎特別不正確的我。如果有問題,我也會用virtualenv來使用Linux。
讓我知道你是否需要更多信息我會仔細監控線程。
編輯:Appologies!我用python3和python 2.7運行它,都沒有工作。下面是跟蹤:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/graphql
Django Version: 1.10.6
Python Version: 2.7.12
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'graphene_django',
'ingredients']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner
42. response = get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in view
62. self = cls(**initkwargs)
File "/usr/local/lib/python2.7/dist-packages/graphene_django/views.py" in __init__
70. schema = graphene_settings.SCHEMA
File "/usr/local/lib/python2.7/dist-packages/graphene_django/settings.py" in __getattr__
116. val = perform_import(val, attr)
File "/usr/local/lib/python2.7/dist-packages/graphene_django/settings.py" in perform_import
60. return import_from_string(val, setting_name)
File "/usr/local/lib/python2.7/dist-packages/graphene_django/settings.py" in import_from_string
78. raise ImportError(msg)
Exception Type: ImportError at /graphql
Exception Value: Could not import 'cookbook.schema.schema' for Graphene setting 'SCHEMA'. ImportError: No module named schema.
你說你運行'python3 manage.py runserver'沒有任何意義,但錯誤顯示Python 2.7。你還沒有顯示完整的回溯,這將顯示導入失敗的地方。 – Alasdair
對不起!我已經在兩種情況下運行它,我將完整的軌跡添加到原始帖子中。 –