2015-08-09 41 views
-1

我有一個可笑的錯誤,而試圖跟隨http://neomodel.readthedocs.org/en/latest/getting_started.html#connecting如何才能名稱空間中的名稱是未定義的Python?

我剛剛卸載了這個環境neo4django因爲它有名字StringProperty,我試圖做的Neo4j的一類:

In [8]: from neomodel import StringProperty as SP 

In [9]: class Person(StructuredNode): 
    ...:  name = SP() 
    ...:  
--------------------------------------------------------------------------- 
NameError         Traceback (most recent call last) 
/home/cchilders/.local/virtualenv/another_neo4django_attempt/local/lib/python2.7/site-packages/django/core/management/commands/shell.pyc in <module>() 
----> 1 class Person(StructuredNode): 
     2  name = SP() 
     3 

/home/cchilders/.local/virtualenv/another_neo4django_attempt/local/lib/python2.7/site-packages/django/core/management/commands/shell.pyc in Person() 
     1 class Person(StructuredNode): 
----> 2  name = SP() 
     3 

NameError: name 'SP' is not defined 

In [10]: S 
%%SVG   StopIteration SyntaxError  SystemExit 
SP    StringProperty SyntaxWarning 
StandardError StructuredNode SystemError 

你可以看到,自動完成證明名稱在那裏。這個neomodel是具體的還是有一個通用的Python原因來存在未定義的名稱?謝謝

+2

嘗試使用'.py'文件運行它。 –

+0

我無法在今晚嘗試更多的沮喪。你有什麼建議可以讓任何neo4j以任何身份工作嗎?我寧願讓它工作在django上,但我已經花了幾十個小時嘗試neo4django,py2neo,neomodel,並且每個人可以花費超過10個小時配置它,而不是單個連接到數據庫 – codyc4321

+0

在你真的得到neo4j使用python嗎? – codyc4321

回答

3
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2 
Type "copyright", "credits" or "license()" for more information. 
>>> from neomodel import StringProperty as SP 
>>> from neomodel import (StructuredNode, IntegerProperty, 
    RelationshipTo, RelationshipFrom) 
>>> 
>>> class Person(StructuredNode): 
    name = SP() 
+0

有趣,它在Ipython之外工作。我以前從來沒有在ipython中遇到這樣一個奇怪的問題,但我會先檢查解釋器 – codyc4321