1

我正在尝试使用 Python、Neo4j、NeoModel 和 Heroku 制作 Web 服务器。而且因为我对 NeoModel 不熟悉,所以我现在正在尝试学习Github 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__'

我正在尝试使用 Heroku 和本地服务器来执行此操作,我NEO4J_REST_URL在两种情况下都在 cmd 中设置了环境变量。在这两种情况下,我都遇到了同样的错误。

如果我删除这两行

inhabitant = RelationshipFrom('Person', 'IS_FROM')
country = RelationshipTo(Country, 'IS_FROM')

我认为它运作良好。

谢谢你的阅读!

4

0 回答 0