I have a graph created with networkX and I am using neonx to import it to neo4j on localhost. I have a networkX type graph called G. Below is the code:
data1 = json_graph.node_link_data(G) H = json_graph.node_link_graph(data1) results = neonx.write_to_neo("", H, 'LINKS_TO') The error I get is:
Traceback (most recent call last): File "/Users/aman/venv/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2961, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-5-0d401e8987b7>", line 31, in <module> results = neonx.write_to_neo("", H, 'LINKS_TO') File "/Users/aman/venv/lib/python3.7/site-packages/neonx/neo.py", line 86, in write_to_neo batch_url = all_server_urls['batch'] KeyError: 'batch' 2 Answers
I believe the issue is that your neo4j instance requires authentication, but neonx doesn't appear to support it.
to disable authentication set: dbms.security.auth_enabled=false (see: )
to verify this is the issue point your browser to: and see if you are prompted for a user and password
Best way is to dump networkx graph and import it into Neo4j.
Advantages:
- You don't need to have a working connection with Neo4j server
- Dump once and load it anywhere anytime. You have saved version/backup.
Dump networkx graph:
nx.write_graphml(g, 'path/to/file.graphml') Load into Neo4j:
- Install apoc plugin for Neo4j from here
- Enable
apoc.import.file.enabled=truein conf/neo4j.conf - Place your graph dump
file.graphmlinimport/folder
cypher-shell -a bolt://localhost:7687 "call apoc.import.graphml('file.graphml', {})" Or in browser:
call apoc.import.graphml('file.graphml', {}) For more details:
1