在Python的NeoModel中使用RelationshipFrom()方法时,get-KeyError:'__文件';
我正在尝试使用Python、Neo4j、NeoModel和Heroku制作web服务器。因为我不熟悉NeoModel,我现在正试图从中学习。我编译这段代码时遇到了麻烦在Python的NeoModel中使用RelationshipFrom()方法时,get-KeyError:'__文件';,python,neo4j,neomodel,Python,Neo4j,Neomodel,我正在尝试使用Python、Neo4j、NeoModel和Heroku制作web服务器。因为我不熟悉NeoModel,我现在正试图从中学习。我编译这段代码时遇到了麻烦 from neomodel import (StructuredNode, StringProperty, IntegerProperty, RelationshipTo, RelationshipFrom) class Country(StructuredNode): code = StringProperty
from neomodel import (StructuredNode, StringProperty, IntegerProperty,
RelationshipTo, RelationshipFrom)
class Country(StructuredNode):
code = StringProperty(unique_index=True, required=True)
# traverse incoming IS_FROM relation, inflate to Person objects
inhabitant = RelationshipFrom('Person', 'IS_FROM')
class Person(StructuredNode):
name = StringProperty(unique_index=True)
age = IntegerProperty(index=True, default=0)
# traverse outgoing IS_FROM relations, inflate to Country objects
country = RelationshipTo(Country, 'IS_FROM')
我犯了这个错误
Traceback (most recent call last):
File "C:\Users\someo_000\Desktop\a.py", line 11, in <module>
class Person(StructuredNode):
File "C:\Users\someo_000\Desktop\a.py", line 16, in Person
country = RelationshipTo(Country, 'IS_FROM')
File "build\bdist.win32\egg\neomodel\relationship_manager.py", line 287, in RelationshipTo
return _relate(cls_name, OUTGOING, rel_type, cardinality, model)
File "build\bdist.win32\egg\neomodel\relationship_manager.py", line 283, in _relate
return RelationshipDefinition(rel_type, cls_name, direction, cardinality, model)
File "build\bdist.win32\egg\neomodel\relationship_manager.py", line 218, in __init__
self.module_file = sys._getframe(4).f_globals['__file__']
KeyError: '__file__'
我认为它工作得很好
谢谢你的阅读 正在尝试将Country对象引用放在关系为to以及Residentiant=RelationshipFrom('Person','IS_FROM')的引号内。Country=RelationshipTo('Country','IS_FROM'))
inhabitant = RelationshipFrom('Person', 'IS_FROM')
country = RelationshipTo(Country, 'IS_FROM')