1

I am attempting to connect to an instance of an Aura cloud database using py2neo. I get a variety of errors as I try different parameters, and cannot figure out how to connect. I'm storing my credentials in a json file, and have confirmed all details are correct.

I can connect using the package neo4j (v4.1.2, released 11/17/2020 - note previous versions on Windows 10 would return security certificate issues). But py2neo does not work with the same credentials.

Code not working:

from py2neo import Graph
import json

with open('secrets/aura_creds.json') as f:
    creds = json.load(f)

URI = creds.get('URI')
USERNAME = creds.get('USERNAME')
PASSWORD = creds.get('PASSWORD')

# connect to database
graph = Graph(URI, auth=(USERNAME, PASSWORD))

Here is code that works with neo4j:

from neo4j import GraphDatabase
import json 

with open('secrets/aura_creds.json') as f:
    creds = json.load(f)

URI = creds.get('URI')
USERNAME = creds.get('USERNAME')
PASSWORD = creds.get('PASSWORD')

graph = GraphDatabase.driver(URI, auth=(USERNAME, PASSWORD))

The error received using py2neo is:

Traceback (most recent call last):
  File "C:\Users\Erik\Documents\_c-dev\essc-knowledge-base\scripts\graph_databas
e.py", line 21, in <module>
    graph = Graph(URI, secure=False, verify=False, auth=(USERNAME, PASSWORD))
  File "C:\Users\Erik\Anaconda3\envs\essc-knowledge-base\lib\site-packages\py2ne
o\database\__init__.py", line 358, in __init__
    self.service = GraphService(profile, **settings)
  File "C:\Users\Erik\Anaconda3\envs\essc-knowledge-base\lib\site-packages\py2ne
o\database\__init__.py", line 181, in __init__
    profile = ConnectionProfile(profile, **settings)
  File "C:\Users\Erik\Anaconda3\envs\essc-knowledge-base\lib\site-packages\py2ne
o\client\config.py", line 166, in __init__
    self._apply_components(**settings)
  File "C:\Users\Erik\Anaconda3\envs\essc-knowledge-base\lib\site-packages\py2ne
o\client\config.py", line 231, in _apply_components
    self.__secure = self._coalesce(settings.get("secure"), self.secure, NEO4J_SE
CURE)
  File "C:\Users\Erik\Anaconda3\envs\essc-knowledge-base\lib\site-packages\py2ne
o\client\config.py", line 305, in secure
    return self.__secure
AttributeError: 'ConnectionProfile' object has no attribute '_ConnectionProfile_
_secure'

Using Windows 8.1 Pro with Python 3.9.0, neo4j 4.1.2 and py2neo v.2020.1.0.

Erik
  • 41
  • 4

1 Answers1

1

Because Neo4j Aura used neo4j version 4, so you have to upgrade to the latest version of Py2neo. Simply use this command:

pip install --upgrade py2neo

Then, the error should be fixed now.