尝试连接neo4j-Python

问题描述 投票:0回答:1

我启动了本地neo4j服务器,并使用Python(PyCharm)使用它,并安装了所有必需的模块(neo4jpy2neoneomodel),都使用Python 3.8。

from neo4j import GraphDatabase, basic_auth

driver = GraphDatabase.driver("bolt://localhost:7687", auth=basic_auth("neo4j", "12345"))
session = driver.session()
session.run("CREATE (a:Person {name:'Bob'})")
result = session.run("MATCH (a:Person) RETURN a.name AS name")

for record in result:
    print(record["name"])

result.close()
session.close()

但是程序启动时,它将返回错误。该怎么办?

D:\PyCharm\projects\venv\Scripts\python.exe add -i D:\PyCharm\plugins\python-ce\helpers\pydev\pydevconsole.py --mode=client --port=52885
D:\Python\python.exe: can't open file 'add': [Errno 2] No such file or directory
Process finished with exit code 2

我该如何解决?

python neo4j pycharm
1个回答
0
投票

可能您的PyCharm Interpreter配置和/或运行配置错误。

尝试从终端而不是从PyCharm使用控制台命令运行代码。

© www.soinside.com 2019 - 2024. All rights reserved.