jupyter / declarativewidgets

[RETIRED] Jupyter Declarative Widget Extension
http://jupyter.org/declarativewidgets/docs.html
Other
120 stars 38 forks source link

declarativewidgets not working #538

Open benvial opened 7 years ago

benvial commented 7 years ago

I can't get declarative widgets to work. The module is loaded but when I try to import a widget nothing happens and I get warnings in the console.

import declarativewidgets as dw
dw.init()
[W 15:27:11.434 NotebookApp] 404 GET /urth_components/urth-core-behaviors/jupyter-notebook-env.html (::1) 6.37ms referer=http://localhost:8888/notebooks/Untitled2.ipynb?kernel_name=python3
[W 15:27:12.097 NotebookApp] 404 GET /static/does/not/exist.js?v=20161228152659 (::1) 1.22ms referer=http://localhost:8888/notebooks/Untitled2.ipynb?kernel_name=python3
[W 15:27:12.109 NotebookApp] 404 GET /nbextensions/widgets/widgets/js/widget.js?v=20161228152659 (::1) 1.53ms referer=http://localhost:8888/notebooks/Untitled2.ipynb?kernel_name=python3
%%html
<link rel='import' href='urth_components/paper-slider/paper-slider.html'
        is='urth-core-import' package='PolymerElements/paper-slider'>
<paper-slider></paper-slider>
[W 15:49:39.063 NotebookApp] 404 GET /notebooks/urth_components/paper-slider/paper-slider.html (::1): No such file or directory: urth_components/paper-slider/paper-slider.html
[W 15:49:39.065 NotebookApp] 404 GET /notebooks/urth_components/paper-slider/paper-slider.html (::1) 2.30ms referer=http://localhost:8888/notebooks/Untitled2.ipynb?kernel_name=python3
[W 15:49:39.068 NotebookApp] 404 GET /nbextensions/declarativewidgets/urth_components/paper-slider/paper-slider.html (::1) 2.04ms referer=http://localhost:8888/notebooks/Untitled2.ipynb?kernel_name=python3
[W 15:49:39.081 NotebookApp] 403 POST /urth_import (::1): '_xsrf' argument missing from POST
[W 15:49:39.082 NotebookApp] 403 POST /urth_import (::1) 1.48ms referer=http://localhost:8888/notebooks/Untitled2.ipynb?kernel_name=python3

I am using a virtualenv, python 3.5 on Opensuse Tumbleweed. Some info:

(venv) bench@linux-i0hp:~/Codes/virtualenv/myapp> jupyter troubleshoot

$PATH:
        /home/bench/Codes/virtualenv/myapp/venv/bin
        /home/bench/Codes/virtualenv/myapp/venv/bin
        /home/bench/bin
        /usr/local/bin
        /usr/bin
        /bin
        /usr/games
        /opt/kde3/bin
        /home/bench/Programs/comsol/v35a/COMSOL35a/bin
        /home/bench/Programs/petsc/petsc-3.6.2
        /usr/local/lib64
        /usr/local/lib
        /usr/lib64/ruby/gems/2.1.0/gems/jekyll-3.2.1/exe
        /usr/lib64/ruby/gems/2.1.0/gems/bundler-1.12.5/exe
        /home/bench/Programs/matlab/R2008b/bin
        /home/bench/.local/bin

sys.path:
        /home/bench/Codes/virtualenv/myapp/venv/bin
        /home/bench/Codes/virtualenv/myapp/venv/lib/python35.zip
        /home/bench/Codes/virtualenv/myapp/venv/lib64/python3.5
        /home/bench/Codes/virtualenv/myapp/venv/lib64/python3.5/plat-linux
        /home/bench/Codes/virtualenv/myapp/venv/lib64/python3.5/lib-dynload
        /usr/lib64/python3.5
        /usr/lib/python3.5
        /home/bench/Codes/virtualenv/myapp/venv/lib/python3.5/site-packages

sys.executable:
        /home/bench/Codes/virtualenv/myapp/venv/bin/python3

sys.version:
        3.5.1 (default, Dec 09 2015, 07:29:36) [GCC]

platform.platform():
        Linux-4.8.14-1-default-x86_64-with-glibc2.3.4

which -a jupyter:
        /home/bench/Codes/virtualenv/myapp/venv/bin/jupyter
        /home/bench/Codes/virtualenv/myapp/venv/bin/jupyter

pip list:
        bleach (1.5.0)
        cycler (0.10.0)
        decorator (4.0.10)
        entrypoints (0.2.2)
        html5lib (0.9999999)
        ipykernel (4.5.2)
        ipython (5.1.0)
        ipython-genutils (0.1.0)
        ipywidgets (5.2.2)
        Jinja2 (2.8)
        jsonschema (2.5.1)
        jupyter (1.0.0)
        jupyter-client (4.4.0)
        jupyter-console (5.0.0)
        jupyter-core (4.2.1)
        jupyter-declarativewidgets (0.7.0)
        MarkupSafe (0.23)
        matplotlib (1.5.3)
        mistune (0.7.3)
        mpmath (0.19)
        nbconvert (5.0.0)
        nbformat (4.2.0)
        notebook (4.3.1)
        numpy (1.11.3)
        pandas (0.19.2)
        pandocfilters (1.4.1)
        pexpect (4.2.1)
        pickleshare (0.7.4)
        pip (9.0.1)
        prompt-toolkit (1.0.9)
        ptyprocess (0.5.1)
        Pygments (2.1.3)
        pyparsing (2.1.10)
        python-dateutil (2.6.0)
        pytz (2016.10)
        pyzmq (16.0.2)
        qtconsole (4.2.1)
        setuptools (32.3.0)
        simplegeneric (0.8.1)
        six (1.10.0)
        sympy (1.0)
        terminado (0.6)
        testpath (0.3)
        tornado (4.4.2)
        traitlets (4.3.1)
        wcwidth (0.1.7)
        wheel (0.29.0)
        widgetsnbextension (1.2.6)

I installed and enabled using:

pip install jupyter_declarativewidgets
jupyter declarativewidgets quick-setup --sys-prefix

And the extension seems installed and activated

(venv) bench@linux-i0hp:~/Codes/virtualenv/myapp> jupyter nbextension list
Known nbextensions:
  config dir: /home/bench/Codes/virtualenv/myapp/venv/etc/jupyter/nbconfig
    notebook section
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
      declarativewidgets/js/main  enabled 
      - Validating: OK

I also have npm (v 2.15.11) and bower (v 1.8.0) installed.

Any help would be greatly appreciated! Please let me know if you need additional info.

JoshuaAcosta commented 7 years ago

Same here except using Python 3.6 on Mac.

dolphinfriendlytuna commented 7 years ago

Same problem on Python 2.7 on Centos7 docker.

I think this is a problem with notebook 4.3.x. The docs indicate that only versions <= 4.2.x are supported.

lbustelo commented 7 years ago

No support for 4.3

lbustelo commented 7 years ago

@benchmars the console 404 error on /static/does/not/exist.js is normal. The fact that it cannot load /urth_components/urth-core-behaviors/jupyter-notebook-env.html points to an installation error. It could very much be something that broke on notebook 4.3.x.

haobibo commented 7 years ago

This seems to be caused by jupyter notebook security upgrade at 4.3.1, described here: https://blog.jupyter.org/2016/12/21/jupyter-notebook-4-3-1/

I think iron-ajax element in the urth-core-import.html should also include a header X-XSRFToken.

var xsrf_token = document.cookie.match("\\b" + name + "=([^;]*)\\b");
var header = xsrf_token ? {'X-XSRFToken': xsrf_token[1]} : {};

Refer to this link to see how to add a header to iron-ajax.