При попытке получить базовое руководство по графену, я столкнулся с ранней проблемой, которая, похоже, не подходит другим, в частности, первоначальный импорт завершился неудачей.
Python 2.7.16, графен 2.1.8Шесть (1.12.0). Я обновил все установленные пакеты через pip.
python -m graphene
Traceback (most recent call last):
File "F:\Python27\lib\runpy.py", line 163, in _run_module_as_main
mod_name, _Error)
File "F:\Python27\lib\runpy.py", line 111, in _get_module_details
__import__(mod_name) # Do not catch exceptions initializing package
File "F:\Python27\lib\site-packages\graphene\__init__.py", line 3, in <module>
from .types import (
File "F:\Python27\lib\site-packages\graphene\types\__init__.py", line 12, in <module>
from .schema import Schema
File "F:\Python27\lib\site-packages\graphene\types\schema.py", line 15, in <module>
from .typemap import TypeMap, is_graphene_type
File "F:\Python27\lib\site-packages\graphene\types\typemap.py", line 33, in <module>
from .enum import Enum
File "F:\Python27\lib\site-packages\graphene\types\enum.py", line 70, in <module>
class Enum(six.with_metaclass(EnumMeta, UnmountedType, BaseType)):
File "F:\Python27\lib\site-packages\six.py", line 827, in __new__
return meta(name, bases, d)
File "F:\Python27\lib\site-packages\graphene\types\enum.py", line 33, in __new__
enum = PyEnum(cls.__name__, enum_members)
File "F:\Python27\lib\site-packages\enum.py", line 199, in __init__
raise EnumBadKeyError(key)
enum.EnumBadKeyError: Enumeration keys must be strings: OrderedDict([
('__module__', 'graphene.types.enum'),
('get_type', <classmethod object at 0x031DADB0>),
('__doc__', '\n Enum type definition\n\n Defines a static set of values that can be provided as a Field, Argument or InputField.\n\n .. code:: python\n\n from graphene import Enum\n\n class NameFormat(Enum):\n FIRST_LAST = "first_last"\n LAST_FIRST = "last_first"\n\n Meta:\n enum (optional, Enum): Python enum to use as a base for GraphQL Enum.\n\n name (optional, str): Name of the GraphQL type (must be unique in schema). Defaults to class\n name.\n description (optional, str): Description of the GraphQL type in the schema. Defaults to class\n docstring.\n deprecation_reason (optional, str): Setting this value indicates that the enum is\n depreciated and may provide instruction or reason on how for clients to proceed.\n '),
('__init_subclass_with_meta__', <classmethod object at 0x031DAD90>),
('__eq__', <function eq_enum at 0x031DBD70>)]