I am trying to write code in Python (MacOS, Python 3.7.6 64-bit, Spyder 4.0.1) but I can't even get the HelloWorld example to work from the "Using Neo4j from Python" section of the Developer Guide. It fails at the first line. "pip list" shows I have the neo4j Python driver 1.7.6. I am running Neo4j Desktop 1.2.4 with Neo4j Browser 4.0.3 (all freshly installed). I have a single empty graph, visible in Neo4j Browser 4.0.3, which indicates I am running Neo4j 4.0.1.
I have read the previous topic on this error message and none of the answers make sense to me / don't work for me that I can see.
Perhaps I have to wait for "the upcoming 2.0 release of the driver"?
Any clues?
from neo4j import GraphDatabase # <--- fails here
class HelloWorldExample(object):
def __init__(self, uri, user, password):
self._driver = GraphDatabase.driver(uri, auth=(user, password))
def close(self):
self._driver.close()
def print_greeting(self, message):
with self._driver.session() as session:
greeting = session.write_transaction(self._create_and_return_greeting, message)
print(greeting)
@staticmethod
def _create_and_return_greeting(tx, message):
result = tx.run("CREATE (a:Greeting) "
"SET a.message = $message "
"RETURN a.message + ', from node ' + id(a)", message=message)
return result.single()[0]