Integrating Jupyter Notebook with Neo4J Desktop Database

Hi,

The data science class teaches how to integrate and setup the development environment for a Sandbox. How can I replicate the same for a Neo4J Desktop based graph database for the community edition?

Not sure I understand the question, but here's an example of connecting to a neo4j database from a notebook in Binderhub: https://mybinder.org/v2/gh/psychemedia/binder-neo4j/master?filepath=py%2Fneo4j-demo.py

Via: https://blog.ouseful.info/2019/08/13/neo4j-graph-database-running-in-mybinder/

1 Like

In general, just connect with the python driver to that database, with bolt://host:port + username + password.

I am using the following:
graph = Graph("bolt://host:7473", auth=("neo4j", ""))

Also tried the other variation:
graph = Graph("bolt://localhost:7473", auth=("neo4j", "<Password"))

Moreover, did try the bolt port, https port and http port. Could you advise which one to use.

I am getting the following error:
KeyError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/py2neo/database.py in new(cls, uri, **settings)
87 try:
---> 88 inst = cls._instances[key]
89 except KeyError:

KeyError: 'ff568088721569ea47d3734156837aa1'

During handling of the above exception, another exception occurred:

ServiceUnavailable Traceback (most recent call last)
10 frames
/usr/local/lib/python3.6/dist-packages/neo4j/bolt/connection.py in _connect(resolved_address, **config)
582 _force_close(s)
583 if error.errno in (61, 99, 111, 10061):
--> 584 raise ServiceUnavailable("Failed to establish connection to {!r} (reason {})".format(resolved_address, error.errno))
585 else:
586 raise

ServiceUnavailable: Failed to establish connection to ('::1', 7474, 0, 0) (reason 99)

Bolt port is. 7687 not one of those you used.

graph = Graph("bolt://localhost:7687", auth=("neo4j", "Jaipur@92"))

I used this and still getting the error

And your notebook server is running locally?

and you imported the python-driver or py2neo dependency?
and installed into your notebook?

I am using the online Jupyter notebook through Google colab.

Yes the other drivers are installed using the following commands:

!pip install py2neo==4.1.3 pandas matplotlib sklearn

from py2neo import Graph

What is the current error message.

KeyError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/py2neo/database.py in new (cls, uri, **settings)
87 try:
---> 88 inst = cls._instances[key]
89 except KeyError:

KeyError: 'ff568088721569ea47d3734156837aa1'

During handling of the above exception, another exception occurred:

ServiceUnavailable Traceback (most recent call last)
10 frames
/usr/local/lib/python3.6/dist-packages/neo4j/bolt/connection.py in _connect(resolved_address, **config)
582 _force_close(s)
583 if error.errno in (61, 99, 111, 10061):
--> 584 raise ServiceUnavailable("Failed to establish connection to {!r} (reason {})".format(resolved_address, error.errno))
585 else:
586 raise

ServiceUnavailable: Failed to establish connection to ('::1', 7474, 0, 0) (reason 99)

But that's again the wrong port in your connection URL.

ServiceUnavailable: Failed to establish connection to ('::1', 7474, 0, 0) (reason 99)

can you make sure you fix all connection URL places first?

KeyError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/py2neo/database.py in new(cls, uri, **settings)
87 try:
---> 88 inst = cls._instances[key]
89 except KeyError:

KeyError: '7e4b1ff0930024bc0b8c7e1d27464215'

During handling of the above exception, another exception occurred:

ServiceUnavailable Traceback (most recent call last)
10 frames
/usr/local/lib/python3.6/dist-packages/neo4j/bolt/connection.py in _connect(resolved_address, **config)
582 _force_close(s)
583 if error.errno in (61, 99, 111, 10061):
--> 584 raise ServiceUnavailable("Failed to establish connection to {!r} (reason {})".format(resolved_address, error.errno))
585 else:
586 raise

ServiceUnavailable: Failed to establish connection to ('::1', 7687, 0, 0) (reason 99)

Looks like an ipv6 issue?

Can yo check in your /etc/hosts what the entry is for localhost and possible add 127.0.0.1

I got the following error when I used graph = Graph("bolt://127.0.01:7687", auth=("neo4j", "Jaipur@92"))

KeyError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/py2neo/database.py in new(cls, uri, **settings)
87 try:
---> 88 inst = cls._instances[key]
89 except KeyError:

KeyError: '5ec4cbd7df2b4ae5c9bc45421a11ca50'

During handling of the above exception, another exception occurred:

ServiceUnavailable Traceback (most recent call last)
10 frames
/usr/local/lib/python3.6/dist-packages/neo4j/bolt/connection.py in _connect(resolved_address, **config)
582 _force_close(s)
583 if error.errno in (61, 99, 111, 10061):
--> 584 raise ServiceUnavailable("Failed to establish connection to {!r} (reason {})".format(resolved_address, error.errno))
585 else:
586 raise

ServiceUnavailable: Failed to establish connection to ('127.0.0.1', 7687) (reason 111)

When I click on local host in Neo4J desktop I get the following:

Browser URL: http://localhost:7474/browser/
Connect URL: bolt://localhost:7687

I am not getting anything when I am using the following command:

graph = Graph("http://localhost:7474/browser/", auth=("neo4j", "Jaipur@92"))

Have an example jupyter notebook hooked up to neo4j as part of the walkscore neo4j demo that might help - although it may be using an older python library as it was done last year: https://github.com/menome/neo4j-spatial-experiments/tree/master/1_walkscore