【问题标题】:Unable to connect py2neo v3 with neo4j 3.4.1无法将 py2neo v3 与 neo4j 3.4.1 连接
【发布时间】:2018-07-23 16:29:00
【问题描述】:

我一直在尝试使用 py2neo v3 和 neo4j 3.4.1 版连接到我的本地 neo4j 服务器。

我使用的命令是:-

from py2neo import Graph, Node, Relationship

graphURL='http://localhost:7474/db/data/'
graphUser = "neo4j"
graphPassphrase = "XXXX"

graph=Graph(graphURL, user=graphUser, password=graphPassphrase)

我在尝试使用此代码时收到以下错误。

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-20-ab3844caf22c> in <module>()
      3 graphPassphrase = "XXXX"
      4 
----> 5 graph=Graph(graphURL, user=graphUser, password=graphPassphrase)

~\Anaconda3\lib\site-packages\py2neo\graph.py in __new__(cls, *uris, **settings)
    333     def __new__(cls, *uris, **settings):
    334         database = settings.pop("database", "data")
--> 335         graph_service = GraphService(*uris, **settings)
    336         address = graph_service.address
    337         if database in graph_service:

~\Anaconda3\lib\site-packages\py2neo\graph.py in __new__(cls, *uris, **settings)
     77         from py2neo.addressing import register_graph_service, get_graph_service_auth
     78         from py2neo.http import register_http_driver
---> 79         from neo4j.v1 import GraphDatabase
     80         register_http_driver()
     81         address = register_graph_service(*uris, **settings)

~\Anaconda3\lib\site-packages\neo4j\v1\__init__.py in <module>()
     20 
     21 from .api import *
---> 22 from .bolt import *
     23 from .security import *
     24 from .types import *

~\Anaconda3\lib\site-packages\neo4j\v1\bolt.py in <module>()
     30 from .security import SecurityPlan, Unauthorized
     31 from .summary import ResultSummary
---> 32 from .types import Record
     33 
     34 

~\Anaconda3\lib\site-packages\neo4j\v1\types\__init__.py in <module>()
     31 from operator import xor as xor_operator
     32 
---> 33 from neo4j.packstream import Structure
     34 from neo4j.compat import map_type, string, integer, ustr
     35 

~\Anaconda3\lib\site-packages\neo4j\packstream\__init__.py in <module>()
     20 
     21 
---> 22 from neo4j.util import import_best as _import_best
     23 
     24 from .structure import Structure

ImportError: cannot import name 'import_best'

我曾尝试使用手册https://py2neo.org/v3/database.html?highlight=relation for v3,但这对我的问题没有用。你能帮我解决这个问题吗?

【问题讨论】:

    标签: python-3.x neo4j py2neo


    【解决方案1】:

    驱动支持BOLTHTTP proctole,但是这里似乎你想使用HTTP一个,驱动正在尝试实例化BOLT ...

    我推荐你使用BOLT,所以你的代码应该是:

    from py2neo import Graph, Node, Relationship
    
    graphHost='localhost'
    graphUser = "neo4j"
    graphPassphrase = "XXXX"
    
    graph=Graph(bolt=true, host=graphHost, user=graphUser, password=graphPassphrase)
    

    如果你真的想使用http:

      graph=Graph(bolt=false, host=graphHost, user=graphUser, password=graphPassphrase)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-29
      • 1970-01-01
      相关资源
      最近更新 更多