From_networkx telling my that dict isn't callable even though documentation says that "layout_function" accepts a dictionary

I’m trying to plot nodes based on XY coordinates. Here’s what I have so far:

points = {0: (45638.801, 55742.448),
 1: (53717.677, 53637.007),
 2: (45670.461, 58929.536),
 3: (54683.019, 58581.992)}

G = nx.Graph()

plot = Plot(width=800, height=800)

graph_renderer = from_networkx(G, points)

But when I run this, I get the following error:

TypeError: 'dict' object is not callable

However, the documentation states that the layout_function parameter can accept a dictionary.

Please always:

  • post stacktraces in their entirety (they contain critical context)
  • provide the package version (e.g. maybe your version to too old, no way to know)

Working on determining the package version; it’s entirely possible that I have Python downloaded twice on my work computer.

…stacktrace? I’m unfamiliar with that term.

Edit: this guy?

TypeError                                 Traceback (most recent call last)
<ipython-input-159-fa2797099a87> in <module>()
     12 #graph_renderer = from_networkx(G, nx.circular_layout, scale=1, center=(0,0))
---> 13 graph_renderer = from_networkx(G, points)
     15 graph_renderer.node_renderer.glyph = Circle(size=15, fill_color=Spectral4[0])

C:\Work\Anaconda\lib\site-packages\bokeh\models\ in from_networkx(graph, layout_function, **kwargs)
     72 =
---> 74         graph_layout = layout_function(graph, **kwargs)
     75         graph_renderer.layout_provider = StaticLayoutProvider(graph_layout=graph_layout)

TypeError: 'dict' object is not callable

You would have to be running a considerably ancient version of Bokeh (0.13 or less) to explain that stack trace. If that is the case, the docs you are looking at are too new, since the ability to pass a dict was a feature added after the 1.0 release. Most of the graph interaction polices also probably don’t exist in 0.13 either (I would guess… it was almost half a decade ago). For reference, Bokeh 3.0 is due to be released soon.

In any case it’s important to refer to docs relevant to the actual release you have installed, especially the older the release is. FYI you can generally get to any version of docs, even if they are not explicitly listed in the dropdown at the top of the page:

1 Like

Yeah, I’m discovering that I have 3 different versions of Anaconda (and the associated files) installed on my work computer. >_<

BTW you can print(bokeh.__version__) in a python interpreter or notebook to see the version that is currently imported.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.