问题
I am very new to neo4j and I am trying to stablish a connection from python3.6 to neo4j. I have installed the driver and I am just getting started with the first steps:
import requests import os import time import urllib from neo4j.v1 import GraphDatabase, basic_auth
GraphDatabase.driver("bolt://localhost:7687", auth=basic_auth("neo4j", "myPass"))
However, already in this step I am getting an error:
driver = GraphDatabase.driver("bolt://localhost:7687", auth=basic_auth("neo4j", "myPass"))
Traceback (most recent call last):
File "<ipython-input-5-9ba197b31f8c>", line 1, in <module>
driver = GraphDatabase.driver("bolt://localhost:7687", auth=basic_auth("neo4j", "myPass"))
File "/Users/backup/anaconda/lib/python3.6/site-packages/neo4j/v1/api.py", line 112, in driver
return driver_class(uri, **config)
File "/Users/backup/anaconda/lib/python3.6/site-packages/neo4j/v1/direct.py", line 56, in __init__
pool.acquire()
File "/Users/backup/anaconda/lib/python3.6/site-packages/neo4j/v1/direct.py", line 37, in acquire
return self.acquire_direct(resolved_addresses[0])
File "/Users/backup/anaconda/lib/python3.6/site-packages/neo4j/bolt/connection.py", line 386, in acquire_direct
connection = self.connector(address)
File "/Users/backup/anaconda/lib/python3.6/site-packages/neo4j/v1/direct.py", line 55, in <lambda>
pool = DirectConnectionPool(lambda a: connect(a, security_plan.ssl_context, **config), self.address)
File "/Users/backup/anaconda/lib/python3.6/site-packages/neo4j/bolt/connection.py", line 457, in connect
raise ServiceUnavailable("Failed to establish connection to {!r}".format(address))
ServiceUnavailable: Failed to establish connection to ('::1', 7687, 0, 0)
Before doing this, I have started neo4j from the Terminal, and the bolt was successfully enabled on localhost:7687.
Any ideas why I might be getting this error?
Thanks a lot in advance
回答1:
I had the same issue, it seems to be that localhost resolves by default to ipv6, which that driver version cannot handle yet.
So I just changed localhost to: 127.0.0.1 and it worked.
回答2:
I'm not sure about that exact error but I had several problems with Python 3.6, so I changed to python 2.7 and it worked. Also, you have to make sure you have the neo4j connection established before trying to connect to your database, which depends from where you have installed neo4j. In my case would be this command: ~/soft/neo4j/bin/neo4j console
来源:https://stackoverflow.com/questions/43093488/neo4j-python-driver-service-unavailable