py2neo.database.work.ClientError: [Security.Unauthorized] The client is unauthorized due to authentication failure

py2neo.database.work.ClientError: [Security.Unauthorized] The client is unauthorized due to authentication failure

我正在学习有关 py2neo 的教程,我正在迈出第一步。

我想连接到我使用命令 graph = Graph()

创建的图表

这是我从一开始就做的:

我打开 Neo4j Desktop (v. 1.3.11),创建一个新项目,然后创建一个新数据库:

添加数据库 > 创建本地数据库

DBMS Name: Neo4j
Password: Neo4j

然后我启动它然后我点击打开,以便 Neo4j 浏览器打开并连接到数据库。

因为我看到我已连接的消息,所以我可以继续。

我正在使用 Anaconda 作为提示。

我输入python来激活pythonshell,输出是:

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

我输入:

from py2neo import Graph

然后

graph = Graph()

但是随后提示returns:

Traceback (most recent call last):
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\client\__init__.py", line 450, in acquire
    cx = self._free_list.popleft()
IndexError: pop from an empty deque

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\database\__init__.py", line 358, in __init__
    self.service = GraphService(profile, **settings)
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\database\__init__.py", line 189, in __init__
    self._connector = Connector(profile, **connector_settings)
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\client\__init__.py", line 603, in __init__
    self.add_pools(self._profile)
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\client\__init__.py", line 631, in add_pools
    on_broken=self._on_broken)
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\client\__init__.py", line 316, in open
    seeds = [pool.acquire() for _ in range(init_size or cls.default_init_size)]
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\client\__init__.py", line 316, in <listcomp>
    seeds = [pool.acquire() for _ in range(init_size or cls.default_init_size)]
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\client\__init__.py", line 460, in acquire
    on_broken=lambda msg: self.__on_broken(msg))
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\client\__init__.py", line 118, in open
    on_release=on_release, on_broken=on_broken)
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\client\bolt.py", line 213, in open
    bolt._hello()
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\client\bolt.py", line 653, in _hello
    self._audit(response)
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\client\bolt.py", line 626, in _audit
    task.audit()
  File "C:\Applicazioni_Tommaso\Phyton\lib\site-packages\py2neo\client\bolt.py", line 1062, in audit
    raise self._failure
py2neo.database.work.ClientError: [Security.Unauthorized] The client is unauthorized due to authentication failure.

我看到问题是出于安全原因,所以我尝试了

graph = Graph("bolt://localhost:7687", user="Neo4j", password="Neo4j")

但是我得到了同样的错误。怎么了?

您正在尝试使用您的 DBMS 名称而不是您的用户名进行身份验证,默认情况下是 neo4j

实际上 Neo4j 浏览器告诉您:

You are connected as user neo4j

to bolt://localhost:7687

所以连接到你的图表的正确命令是

graph = Graph("bolt://localhost:7687", user="neo4j", password="Neo4j")