yWorks / yfiles-jupyter-graphs

The home of the Jupyter notebook graph visualization widget powered by yFiles for HTML
https://www.yworks.com/products/yfiles-graphs-for-jupyter
Other
162 stars 15 forks source link

Failed to load model class 'GraphModel' from module 'yfiles-jupyter-graphs' #50

Closed Moris-Zhan closed 5 months ago

Moris-Zhan commented 6 months ago

Describe the bug [Open Browser Console for more detailed log - Double click to close this message] Failed to load model class 'GraphModel' from module 'yfiles-jupyter-graphs' Error: No version of module yfiles-jupyter-graphs is registered

Expected behavior A clear and concise description of what you expected to happen.

Screenshots image

image

Desktop (please complete the following information):

yGuy commented 6 months ago

Did you reload jupyter notebook and restart the kernel after running the installation?

sanjeev-bhandari commented 5 months ago

@Moris-Zhan Restarting kernel only didnot helped me

But, i exited the jupyter notebook, then reopen jupyter notebook. This helped me load the widgets.

ABoghiBOE commented 3 months ago

I have this problem as well. Additionally I get this message:

Failed to load model class 'GraphModel' from module 'yfiles-jupyter-graphs' Error: No version of module yfiles-jupyter-graphs is registered

Thanks for any help.

yGuy commented 3 months ago

@ABoghiBOE - did you reload the browser and reopen the notebook after installing the widget? This is a known issue with the way the widget registry works in jupyter notebooks - google colab does not show this problem.

ABoghiBOE commented 3 months ago

Dear @yGuy thank you for yoru quick reply. I didn't notice I had to install the widgets. I run:

conda install conda-forge::jupyterlab_widgets

to remediate and then I did:

jupyter lab build

That solved it. Thanks

Jenspade commented 3 months ago

I am having the same problem, the error is Failed to load model class 'GraphModel' from module 'yfiles-jupyter-graphs' Error: Script error for "yfiles-jupyter-graphs"

yGuy commented 3 months ago

Hi @Jenspade if it really is the same problem, then the same solutions above should work. Have you tried these? If not, please do provide more details. This is typically not an issue with the plugin itself, but an issue with its installation into the environment. So details about the environment and about how you installed the plugin would be helpful. Typically there should be more details abou the "script error" in any of the involved consoles.

Jenspade commented 3 months ago

Hi, thanks for the quick response, I tried the recommended solutions

When I run the code to get the Neo4j graph, I get <neo4j.graph.Graph at 0x1391043d0> so I believe that part works. I am connected to Neo4j database as my other queries to get table information into a dataframe work.

In Jupyter Notebooks, I have installed !pip install yfiles_jupyter_graphs from yfiles_jupyter_graphs import GraphWidget

macOS: Sonoma 14.5 Chrome: Version 126.0.6478.63

Selected Jupyter core packages... IPython : 8.20.0 ipykernel : 6.28.0 ipywidgets : 8.1.3 jupyter_client : 7.4.9 jupyter_core : 5.5.0 jupyter_server : 2.10.0 jupyterlab : 3.6.7 nbclient : 0.8.0 nbconvert : 7.10.0 nbformat : 5.9.2 notebook : 6.5.4 qtconsole : 5.4.2 traitlets : 5.7.1

This is the error [Open Browser Console for more detailed log - Double click to close this message] Failed to load model class 'GraphModel' from module 'yfiles-jupyter-graphs' Error: Script error for "yfiles-jupyter-graphs" http://requirejs.org/docs/errors.html#scripterror at makeError (http://localhost:8890/static/components/requirejs/require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:168:17) at HTMLScriptElement.onScriptError (http://localhost:8890/static/components/requirejs/require.js?v=d37b48bb2137faa0ab98157e240c084dd5b1b5e74911723aa1d1f04c928c2a03dedf922d049e4815f7e5a369faa2e6b6a1000aae958b7953b5cc60411154f593:1735:36)

Thanks

yGuy commented 3 months ago

Can you install the plugin via anaconda or globally along with your notebook? Also is this jupyter notebook or jupyter lab?

Also, there should be more information about the "script" error, somewhere. You can "break on exception" in your Chrome developer tools and see what this ominous error is all about?

There are tons of similar problems on the internet with ipywidgets not installing properly, most of the time its incompatibilities with the jupyter widget manager and other packages and how they are installed. But I wasn't successful with the "script error" with a very quick search...

fskpf commented 3 months ago

@Jenspade another thing to add:

You mentioned that you've installed it from within a Jupyter Notebook cell via

!pip install yfiles_jupyter_graphs

This often does not work, because the pip you are running there is not necessarily connected to the Python that runs your notebook. For an in-depth explanation, see https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/

When installing from within a Jupyter Notebook cell, always use

%pip install <package_name>

And, of course, restart the kernel afterward.

Jenspade commented 3 months ago

Thanks for the tip!

yGuy commented 3 months ago

Maybe @fskpf you should mention that prominently in the README - did it work for you @Jenspade ?

Jenspade commented 3 months ago

Hi, no, it didn't work, same error. To answer your previous questions, I am using jupyter notebook. I also installed the plugin via terminal as well as in jupyter notebook

yGuy commented 3 months ago

Can you try to find more information about the error using the developer console?

If nothing else helps, I can only recommend to use Google Colab or setup a fresh new instance of jupyter notebook, e.g. using docker. This typically works and avoid all the problems that an old installation with tons of mismatching packages brings to the table.

Jenspade commented 3 months ago

I want to thank you for all your help and suggestions, but I am under a time constraint and cannot afford the time to find a suitable solution, so I will abandon trying to visualize the Neo4j graphs interactively in Python, but thanks again!

fskpf commented 3 months ago

As future reference, I just successfully tried it in a fresh conda environment like so:

> conda create -n jupyternotebooktest -c conda-forge python notebook
> conda activate  jupyternotebooktest
(jupyternotebooktest)> pip install yfiles-jupyter-graphs
(jupyternotebooktest)> jupyter notebook

Then open the introduction notebook and run all cells.

For Jupyter Lab, you'd have to install jupyterlab instead of notebook.

Jenspade commented 3 months ago

I did what you said

Screenshot 2024-06-24 at 8 55 10 AM
fskpf commented 3 months ago

In your screenshot, the execution order of your cells is out of order: The import is run after the usage in the lower cell (see the [1] and [2] in the beginning of each cell).

If I run it in this order, then I'll get the exact same error as in your screenshot. Please try Run -> Run All Cells (or make sure that the cells are executed in the correct order): image

Jenspade commented 3 months ago

Thank you so much it works now!! Again, thank you for your persistence. I was about to give up.

Screenshot 2024-06-24 at 10 48 41 AM