Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python的NeoModel中使用RelationshipFrom()方法时,get-KeyError:'__文件';_Python_Neo4j_Neomodel - Fatal编程技术网

在Python的NeoModel中使用RelationshipFrom()方法时,get-KeyError:'__文件';

在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

我正在尝试使用Python、Neo4j、NeoModel和Heroku制作web服务器。因为我不熟悉NeoModel,我现在正试图从中学习。我编译这段代码时遇到了麻烦

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')