nglviewer / nglview

Jupyter widget to interactively view molecular structures and trajectories
http://nglviewer.org/nglview/latest/
Other
821 stars 134 forks source link

Could not instantiate widget #696

Closed lenhsherr closed 7 years ago

lenhsherr commented 7 years ago

Hi, I'm testing a script on two Macs, and despite apparently identical setup, the widget does not show up on only one of them.

Javascript control panel shows this. `[Error] Could not instantiate widget [Error] Error: Could not create a model. — utils.js:109 [Error] Couldn't process kernel message – "Class NGLModel not found in module nglview-js-widgets" [Error] Unhandled Promise Rejection: Class NGLModel not found in module nglview-js-widgets'

What does this mean?

1.0.b2 nglview 7.0.0 ipywidgets

hainm commented 7 years ago

try this

jupyter-nbextension enable nglview --py --sys-prefix
gph82 commented 7 years ago

On a fresh install on I am not sure if it is the same issue (JS console does not say anything) but the terminal from which the nb was started says

[W 11:39:47.413 NotebookApp] 404 GET /nbextensions/nglview.js?v=20170928113941 (::1) 2.16ms referer=http://localhost:8888/notebooks/Figure_summary.ipynb                                                                                     
[W 11:39:47.588 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20170928113941 (::1) 2.07ms referer=http://localhost:8888/notebooks/Figure_summary.ipynb    

I'm on Linux w Debian Stretch have enabled the nbtextensions and

ipywidgets                7.0.0            py36h7b55c3a_0    https://repo.continuum.io/pkgs/main
nglview                   1.0b2                     <pip>
widgetsnbextension        3.0.2            py36hd01bb71_1    https://repo.continuum.io/pkgs/main

Debugging a non instantiated widget is the hardest thing to do with nglview....

gph82 commented 7 years ago

Okay, the 404 thing was unrelated, but still cannot instantiate....and the error is the same as above, any pointers will be appreciated screenshot_20170928_152811

hainm commented 7 years ago

so does the ipywidgets work?

import ipywidgets
ipywidgets.Text("hello")
gph82 commented 7 years ago

yeah that works no problem

hainm commented 7 years ago

"Class NGLModel not found in module nglview-js-widgets"

mean: the nglview-js-widgets is still the old version. We do have that here: https://github.com/arose/nglview/blob/v1.0.b2/js/src/widget_ngl.js#L17

Not sure why.

hainm commented 7 years ago
screen shot 2017-09-28 at 9 35 10 am

I've tried above with new conda nev

conda create -n debug_nglview python=3.6 numpy
source activate debug_nglview
pip install nglview==1.0b2
nglview enable # same as: jupyter-nbextension enable nglview --py --sys-prefix
jupyter nbextension enable --py --sys-prefix widgetsnbextension # enable ipywidgets since we installed via pip
jupyter notebook
gph82 commented 7 years ago

sooo....anything I can do on my side? TBH, getting nglview to work is always a bit of mystery to me

hainm commented 7 years ago

getting nglview to work is always a bit of mystery to me

welcome to club. That's the way ipywidgets works.

gph82 commented 7 years ago

yes...but, you don't have any other pointers? I don't really understand what you mean with this comment https://github.com/arose/nglview/issues/696#issuecomment-332837466

hainm commented 7 years ago

It meant that nglview-js-widgets supposed to have "NGLModel" but you don't have that. The NGLModel is introduced recently.

hainm commented 7 years ago

sooo....anything I can do on my side?

Uninstall nglview and its JS components and

pip install nglview==1.0.b2
nglview enable

PS: Per uninstall, besides pip uninstall nglview (do it several times) or (conda uninstall nglview), would be safer to delete the folder miniconda3/share/jupyter/nbextensions/nglview-js-widgets (or similar path).

gph82 commented 7 years ago

yeah I've been doing install/remove/reinstall (via conda and pip) very often, still cannot get it to work. Will do and report back. What do you mean to unintall the JS component of nglview...does it not unisntall itself?

hainm commented 7 years ago

does it not unisntall itself?

I have no idea. Normally it will be overwritten by installing new nglview version. Just be sure.

Depending on how you activate the nglview-js-widgets and your path, you can try to find it via

cd $HOME
find . -name nglview-js-widgets

Ideally, that folder should be in miniconda{version}/shared/jupyter/nbextensions/

gph82 commented 7 years ago

got it, it think. This guy seems to be the culprit: ./.local/share/jupyter/nbextensions/nglview-js-widgets/

It would be really helpful to have a trouble-shooting/FAH section on your page. Like, things to try if the widget is not being shown

hainm commented 7 years ago

Yeah, we ar a bit lazy now. Welcome to contribute anything. In worse case, just open issue here.

On Thu, Sep 28, 2017 at 10:34 AM Guillermo Pérez-Hernández < notifications@github.com> wrote:

got it, it think. This guy seems to be the culprit: ./.local/share/jupyter/nbextensions/nglview-js-widgets/

It would be really helpful to have a trouble-shooting/FAH section on your page. Like, things to try if the widget is not being shown

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/arose/nglview/issues/696#issuecomment-332856056, or mute the thread https://github.com/notifications/unsubscribe-auth/AEPuddyujaYyhPmhM1JN7vqmxSAqIHCNks5sm66GgaJpZM4PmH22 .

lenhsherr commented 7 years ago

Thanks, I'm able to fix it with jupyter-nbextension enable nglview --py --sys-prefix

There seems to be two command in the tutorial for enabling the widget:

jupyter-nbextension enable nglview --py --sys-prefix jupyter nbextension enable nglview --py --sys-prefix

It seems for <1.0 only the second one works, but for 1.0 only the first one, although it could just be me. Whats the difference here?

hainm commented 7 years ago

I think they are thgoing same.

On Thu, Sep 28, 2017 at 10:54 AM Haotian notifications@github.com wrote:

Thanks, I'm able to fix it with jupyter-nbextension enable nglview --py --sys-prefix

There seems to be two command in the tutorial for enabling the widget:

jupyter-nbextension enable nglview --py --sys-prefix jupyter nbextension enable nglview --py --sys-prefix

It seems for <1.0 only the second one works, but for 1.0 only the first one, although it could just be me. Whats the difference here?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/arose/nglview/issues/696#issuecomment-332862339, or mute the thread https://github.com/notifications/unsubscribe-auth/AEPudbmvrR28vhhiIGkwSQvLOAhE4ZB1ks5sm7MKgaJpZM4PmH22 .

hainm commented 7 years ago

enjoy, guys.

hainm commented 7 years ago

@gph82 so I am collection FAQ here: https://github.com/arose/nglview/blob/master/docs/FAQ.md

marscher commented 6 years ago

I can also confirm that the ~/.local/share/jupyter/nbextension/nglview-js-widgets containing an old (pip install) made everthing fail. Does the this directory has a higher preference over sys-prefix? I would be worth adding it to the FAQ.

hainm commented 6 years ago

Does the this directory has a higher preference over sys-prefix?

Yes

and thanks, will update FAQ. After 1.0, there won't be any issue like that anymore. For now, please just delete the ~/.local/share/jupyter/nbextension/nglview-js-widgets folder.

Hai

On Mon, Dec 4, 2017 at 11:16 AM, Martin K. Scherer <notifications@github.com

wrote:

I can also confirm that the ~/.local/share/jupyter/nbextension/nglview-js-widgets containing an old (pip install) made everthing fail. Does the this directory has a higher preference over sys-prefix? I would be worth adding it to the FAQ.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/arose/nglview/issues/696#issuecomment-349012281, or mute the thread https://github.com/notifications/unsubscribe-auth/AEPudcYSVFu2dh9tvmfcX814qSYGd_bqks5s9BrjgaJpZM4PmH22 .

hainm commented 6 years ago

update FAQ here, hopefully it's clear: https://github.com/arose/nglview/blob/master/docs/FAQ.md