Error running networkx example, mistake with import from_networkx

One of the examples at https://docs.bokeh.org/en/latest/docs/user_guide/graph.html includes the following line of code:

from bokeh.plotting import figure, from_networkx

This generates the following error:

ImportError: cannot import name ‘from_networkx’

It appears the correct import command is:

from bokeh.models.graphs import from_networkx

Am I missing something or should the example be updated? Thanks for any help you can provide.

Hi @jsale I’m not sure what is going on with your local setup, but the location in the docs is the correct one, as can be seen from the API imports here:

https://github.com/bokeh/bokeh/blob/master/bokeh/plotting/__init__.py

Also, for every embedded example in the docs, the code alongside is the actual code that was executed to generate the example, so if the example is visible, the code must necessarily be working. Perhaps a corrupted install somehow?

Yes, my mistake. I was running the wrong environment and had not updated bokeh 1.4 to 2.0. Thanks fore reminding me to check the api and versions. Nevermind. I don’t appear to be able to delete this post. Please delete if appropriate.