Reputation: 21
I have been trying to connect to my local neo4j server using py2neo v3 and neo4j version 3.4.1.
The commands I used are:-
from py2neo import Graph, Node, Relationship
graphURL='http://localhost:7474/db/data/'
graphUser = "neo4j"
graphPassphrase = "XXXX"
graph=Graph(graphURL, user=graphUser, password=graphPassphrase)
I receive the following errors on trying to use this code.
---------------------------------------------------------------------------
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'
I have tried using the handbook https://py2neo.org/v3/database.html?highlight=relation for v3 but it was of no use for my problem. Could you please help me with this issue.
Upvotes: 2
Views: 858
Reputation: 7458
The driver support the BOLT
and HTTP
proctole, but it seems here that you want to use the HTTP
one, and the driver is trying to instantiate the BOLT
...
I recommend you to use BOLT
, so your code should be :
from py2neo import Graph, Node, Relationship
graphHost='localhost'
graphUser = "neo4j"
graphPassphrase = "XXXX"
graph=Graph(bolt=true, host=graphHost, user=graphUser, password=graphPassphrase)
If you really want to use the http :
graph=Graph(bolt=false, host=graphHost, user=graphUser, password=graphPassphrase)
Upvotes: 1