I've seen this symptom reported in other issues, but so far have found no resolution. As a minimal test, I am attempting the following notebook commands:
from ipywidgets import IntSlider
IntSlider()
The result is:
Widget Javascript not detected. It may not be installed or enabled properly.
Error rendering Jupyter widget. Widget not found: {"model_id":"c666e150707e45d994d5c53aff96a6d5"}
If I open the Chrome inspector I see that the jupyter-js-widgets/extension was loaded, but also see the following error:
Wrong widget protocol version: received protocol version '', but was expecting major version '2'
ManagerBase.handle_comm_open @ manager-base.js:134
(anonymous) @ comm.js:89
Promise resolved (async)
CommManager.comm_open @ comm.js:85
i @ jquery.min.js:4
Kernel._handle_iopub_message @ kernel.js:1223
Kernel._finish_ws_message @ kernel.js:1015
(anonymous) @ kernel.js:1006
Promise resolved (async)
Kernel._handle_ws_message @ kernel.js:1006
i @ jquery.min.js:4
I'm working in Anaconda and I'm getting this error with both Python 3.5 and 3.6 environments. I got it with both ipywidgets 6 and 7. Obviously I have tried running '_jupyter nbextension enable --py widgetsnbextension --sys-prefix_', although to be clear, it is my understanding that conda should run that for me anyway. At any rate, running that command reports that the extension is enabled and validated. At this point, I've tried every combination I can think of. I'm totally dead in the water. What do I do now?
Desperate. _Help!_ Thanks.
That combination of messages comes from having widgetsnbextension 3.0 installed with ipywidgets 6.0. I think upgrading to ipywidgets 7 will solve the issue. If not, can you post conda list (relevant parts being ipywidgets and widgetsnbextension), and (in python) import ipywidgets; ipywidgets.__version__ and import widgetsnbextension; widgetsnbextension.__version__
it is my understanding that conda should run that for me anyway.
Only for the conda-forge package. Anaconda has a policy against running code, so the Anaconda package does not do it.
Hmmm, well apparently I'm running ipywidgets 7, from conda-forge no less:
$ conda list
# packages in environment at /Users/kwiley/anaconda/envs/python_3_5:
[...]
ipywidgets 7.0.0 py35_1 conda-forge
[...]
widgetsnbextension 3.0.2 py35_0
[...]
I see this confirmed in python as well:
$ python
Python 3.5.4 |Continuum Analytics, Inc.| (default, Aug 14 2017, 12:43:10)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipywidgets; ipywidgets.__version__
'7.0.0'
>>> import widgetsnbextension; widgetsnbextension.__version__
'3.0.2'
>>>
However, it admittedly gets a little weird when I run from either ipython (the nonnotebook version in the terminal) or from ipython/jupyter notebook:
$ ipython
Python 2.7.12 (default, Oct 11 2016, 14:42:23)
Type "copyright", "credits" or "license" for more information.
IPython 5.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import ipywidgets; ipywidgets.__version__
Out[1]: '5.2.2'
In [2]: import widgetsnbextension; widgetsnbextension.__version__
Out[2]: '1.2.6'
And from the notebook:
In [1]: import ipywidgets; ipywidgets.__version__
Out[1]: '6.0.0'
In [2]: import widgetsnbextension; widgetsnbextension.__version__
Out[2]: '3.0.2'
Soooo, my ipython and/or jupyter system is not operating correctly. I guess I need to figure out why/how ipython and jupyter are configured relative to python itself, all wrapped up through Anaconda's intended resource/dependency management system. I realize this is now somewhat off topic of ipywidgets, but if you have any pointers, I would appreciate it. Otherwise, I'll look into this on my own of course.
Thanks.
Some ideas for debugging this:
ipywidgets.__file__~/.local/bin in your path? Or some other directory? Check the output ofwhich pythonwhich jupyterwhich ipythonjupyter nbextension list to see where it sees enabled packages.Also, at least for the notebook, if you have multiple environments, make sure the kernel is in the same environment. I'd also print out widgetsnbextension.__file__ to see exactly where it is installed.
It looks like your ipython is starting up python 2.7, so that's not the same environment as your python 3.5. Perhaps ipython is falling back to your root environment instead of your python 3.5 environment?
Personally, I now do not use the root environment for anything, and have very little installed there. I only work in non-root environments, because I was often getting confused and falling back to the root environment if I forgot to install something in the working environment.
Thank you everyone. I'm not entirely sure which desperate action fixed it. Surely getting the right combination of versions helped. At any rate, it has been working for a few days now. I'm on to other problems now, primarily how to grasp control over the CSS and related styling elements of the widgets so I can design their appearance to my needs. I'll leave that to other issue reports though.
Thanks.
Most helpful comment
That combination of messages comes from having widgetsnbextension 3.0 installed with ipywidgets 6.0. I think upgrading to ipywidgets 7 will solve the issue. If not, can you post
conda list(relevant parts being ipywidgets and widgetsnbextension), and (in python)import ipywidgets; ipywidgets.__version__andimport widgetsnbextension; widgetsnbextension.__version__Only for the conda-forge package. Anaconda has a policy against running code, so the Anaconda package does not do it.