我已经开始通过使用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
对不起!我已经在两种情况下运行它,我将完整的轨迹添加到原始帖子中。 –