我正在尝试使用以下代码将networkx图写入neo4j-
import neonx
import networkx as nx
import json import datetime
G = nx.Graph() G.add_nodes_from([1, 2, 3]) G.add_edge(1, 2)
G.add_edge(2, 3) data = neonx.get_geoff(G, "LINKS_TO")
class DateEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, datetime.date):
return o.strftime('%Y-%m-%d')
return json.JSONEncoder.default(self, o)
data = neonx.get_geoff(G, "LINKS_TO", DateEncoder())
results = neonx.write_to_neo("http://localhost:11002/db/data/", G, 'LINKS_TO')
我在最后一行出现错误,如下所示:
KeyError Traceback (most recent call
last) <ipython-input-25-34d13b5ab90b> in <module>
17
18 data = neonx.get_geoff(G, "LINKS_TO", DateEncoder())
---> 19 results = neonx.write_to_neo("http://localhost:11002/db/data/", G, 'LINKS_TO')
~\Anaconda3\lib\site-packages\neonx\neo.py in write_to_neo(server_url,
graph, edge_rel_name, encoder)
84
85 all_server_urls = requests.get(server_url).json()
---> 86 batch_url = all_server_urls['batch']
87
88 data = generate_data(graph, edge_rel_name, encoder)
KeyError: 'batch'
我的服务器已启动并正在运行,但不确定为什么会出现此键盘错误。有关如何解决此问题的任何想法?