cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to install neo4j for Python/Jupyter Lab?

I tried:
pip install neo4j

But it can't find the module:

from neo4j import GraphDatabase

ModuleNotFoundError: No module named 'neo4j'

1 ACCEPTED SOLUTION

vignes_k1
Node Clone
  1. Launch anconda (i use this) and launch notebook
  2. Launch Neo4j Desktop and start a database you want to connect to.
  3. IN the Jupyter notebook. (basically installs py2neo into your environment)
    Type our the following in separate lines to first install py2neo, then import the library and finally use the features. How to use the full features of py2neo is available in the py2neo documentation above.
pip install py2neo
from py2neo import Graph
graph = Graph("bolt://localhost:7687", auth=("neo4j", "asdfgh123"))
uery = "MATCH (n) return n"
graph.run(query).data()

This would be the simplest way to connect and retrieve results. Add on queries to run to perform additional steps on your data.

View solution in original post

9 REPLIES 9

Thanks, is py2neo the preferred way to interact with neo4j in Python?

pip install neo4j working for me. Check if pip has completed without any error and package is available in site-packages.

import sys
sys.path

and py2neo is community driver

Thanks, the import works fine just using python, but it can't find the package in Jupyter Lab.

I've got the import to work in Jupyter Lab by installing jupyterlab in the same conda environment.

The documentation is not clear what to do next, e.g., how to connect to a database, how to create a new database using Cypher. Where can I find good examples?

vignes_k1
Node Clone
  1. Launch anconda (i use this) and launch notebook
  2. Launch Neo4j Desktop and start a database you want to connect to.
  3. IN the Jupyter notebook. (basically installs py2neo into your environment)
    Type our the following in separate lines to first install py2neo, then import the library and finally use the features. How to use the full features of py2neo is available in the py2neo documentation above.
pip install py2neo
from py2neo import Graph
graph = Graph("bolt://localhost:7687", auth=("neo4j", "asdfgh123"))
uery = "MATCH (n) return n"
graph.run(query).data()

This would be the simplest way to connect and retrieve results. Add on queries to run to perform additional steps on your data.

Thanks, that does it!

The examples I found online just did:
graph = Graph()

and that obviously didn't work.

glad that i could of help