簡體   English   中英

Neo4j Python py2neo授權錯誤

[英]Neo4j Python py2neo authorization error

在Windows 8.1上安裝Neo4j 2.2.3。 沒什么特別的。 通過Neo4j啟動應用程序啟動服務器。 沒有什么特別的東西開始使用py2neo,就像Neo4j.org上的文檔一樣。 進入授權錯誤我無法解釋。 記錄如下。

一個特別的評論:盡管python \\ script在路徑中,但python shell只能從C:\\ python34 \\ python開始。

請解釋我做錯了什么,可以改進。

日志:

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. Alle rechten voorbehouden.

C:\Users\Fred>c:\Python34\python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from py2neo import Graph
>>> graph = Graph()
>>> from py2neo import Node, Relationship
>>> Z1 = Node("Zoeker", naam="Zoeker 1")
>>> O1 = Node("Opleiding", naam="Opleiding 1")
>>> Z1_heeft_O1 = Relationship(Z1, "heeft", O1)
>>> graph.create(Z1_heeft_O1)
Traceback (most recent call last):
  File "c:\Python34\lib\site-packages\py2neo\core.py", line 258, in get response = self.__base.get(headers=headers, redirect_limit=redirect_limit, **kwargs)
  File "c:\Python34\lib\site-packages\py2neo\packages\httpstream\http.py", line 966, in get return self.__get_or_head("GET", if_modified_since, headers, redirect_limit, **kwargs)
  File "c:\Python34\lib\site-packages\py2neo\packages\httpstream\http.py", line 943, in __get_or_head return rq.submit(redirect_limit=redirect_limit, **kwargs)
  File "c:\Python34\lib\site-packages\py2neo\packages\httpstream\http.py", line 452, in submit return Response.wrap(http, uri, self, rs, **response_kwargs)
  File "c:\Python34\lib\site-packages\py2neo\packages\httpstream\http.py", line 489, in wrap raise inst 
py2neo.packages.httpstream.http.ClientError: 401 Unauthorized

在處理上述異常期間,發生了另一個異常:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Python34\lib\site-packages\py2neo\core.py", line 712, in create statement = CreateStatement(self)
  File "c:\Python34\lib\site-packages\py2neo\cypher\create.py", line 44, in __init__ self.supports_node_labels = self.graph.supports_node_labels
  File "c:\Python34\lib\site-packages\py2neo\core.py", line 1086, in supports_node_labels return self.neo4j_version >= (2, 0)
  File "c:\Python34\lib\site-packages\py2neo\core.py", line 964, in neo4j_version return version_tuple(self.resource.metadata["neo4j_version"])
  File "c:\Python34\lib\site-packages\py2neo\core.py", line 213, in metadata self.get()
  File "c:\Python34\lib\site-packages\py2neo\core.py", line 261, in get raise Unauthorized(self.uri.string)
py2neo.error.Unauthorized: http://localhost:7474/db/data/
>>>

neo4j 2.2引入了默認啟用的身份驗證 當您第一次打開Web界面(通常是http://localhost:7474/browser )時,系統會要求您設置用戶名/密碼。 默認為neo4j / neo4j。

以下是如何在py2neo中使用身份驗證:

from py2neo import authenticate, Graph

# set up authentication parameters
authenticate("camelot:7474", "arthur", "excalibur")

# connect to authenticated graph database
graph = Graph("http://camelot:7474/db/data/")

請參閱: http//py2neo.org/2.0/essentials.html#py2neo.authenticate

就我而言,這很有用。

在libexec / conf下,找到neo4j.conf文件夾。

刪除“dbms.security.auth_enabled = false”之前的#

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM