Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use both a built-in widget and a custom widget in JupyterLab #2053

Closed
jonmmease opened this issue Apr 17, 2018 · 3 comments
Closed
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Milestone

Comments

@jonmmease
Copy link

Background

I've been working on adding JupyterLab ipywidget support (In addition to the working notebook ipywidget support) to the this WIP plotly.py branch (plotly/plotly.py#942), and I'm running into a problem.

Problem (Bug?)

A custom-built local widget can't be displayed in the same jupyterlab notebook as a built-in widget provided by @jupyter-widgets/jupyterlab-manager

Simplified Example

Steps to reproduce

  1. Create a fresh conda environment for Python 3.6. Install jupyterlab into the environment using pip
$ conda create -n jupyterlab_widget python=3.6
$ source activate jupyterlab_widget
$ pip install jupyterlab
  1. Follow jupyter widget cookiecutter instructions here to create a new widget named jlwidget
$ pip install cookiecutter
$ cookiecutter https://github.com/jupyter/widget-cookiecutter.git
  1. Build the widget
$ cd jlwidget/
$ python setup.py build
$ pip install -e .
  1. Install widget for notebook
$ jupyter nbextension enable --py widgetsnbextension
$ jupyter nbextension install --py --symlink --sys-prefix jlwidget
$ jupyter nbextension enable --py --sys-prefix jlwidget
  1. Test in classic notebook. Create an IntSlider in the first cell and a HelloWorld widget in the second cell. Both display properly.
$ jupyter notebook

screen shot 2018-04-17 at 6 47 05 am

  1. Build/install for jupyterlab. Note: my understanding is that @jupyter-widgets/jupyterlab-manager needs to be installed to view any widgets in JupyterLab and to view the IntSlider
$ jupyter labextension install @jupyter-widgets/jupyterlab-manager
$ jupyter labextension install js
  1. Test in jupyterlab. Execute the same notebook shown above. The HelloWorld widget displays fine but there is an error displaying the IntSlider
$ jupyter lab

screen shot 2018-04-17 at 6 56 02 am

Here is the error in the chrome developer console

screen shot 2018-04-17 at 6 58 13 am

  1. Disable the jlwidget widget, and repeat the experiment. Now the IntSlider displays fine, and the HelloWorld widget does not (as I expected)
$ jupyter labextension disable jlwidget

screen shot 2018-04-17 at 7 01 21 am

screen shot 2018-04-17 at 7 02 42 am

Environment details

(jupyterlab_widget) measejm1@measejm1-ml1 ~/Programming/PyDataStack/repos/scratch/jlwidget $ conda list
# packages in environment at /Users/measejm1/anaconda/envs/jupyterlab_widget:
#
# Name                    Version                   Build  Channel
appnope                   0.1.0                     <pip>
arrow                     0.12.1                    <pip>
backcall                  0.1.0                     <pip>
binaryornot               0.4.4                     <pip>
bleach                    2.1.3                     <pip>
bqplot                    0.10.5                    <pip>
ca-certificates           2018.03.07                    0  
certifi                   2018.1.18                py36_0  
chardet                   3.0.4                     <pip>
click                     6.7                       <pip>
cookiecutter              1.6.0                     <pip>
decorator                 4.3.0                     <pip>
entrypoints               0.2.3                     <pip>
future                    0.16.0                    <pip>
html5lib                  1.0.1                     <pip>
idna                      2.6                       <pip>
ipykernel                 4.8.2                     <pip>
ipython                   6.3.1                     <pip>
ipython-genutils          0.2.0                     <pip>
ipywidgets                7.2.1                     <pip>
jedi                      0.12.0                    <pip>
Jinja2                    2.10                      <pip>
jinja2-time               0.2.0                     <pip>
jlwidget                  0.1.0a0                   <pip>
jsonschema                2.6.0                     <pip>
jupyter-client            5.2.3                     <pip>
jupyter-core              4.4.0                     <pip>
jupyterlab                0.32.0                    <pip>
jupyterlab-launcher       0.10.5                    <pip>
libcxx                    4.0.1                h579ed51_0  
libcxxabi                 4.0.1                hebd6815_0  
libedit                   3.1                  hb4e282d_0  
libffi                    3.2.1                h475c297_4  
MarkupSafe                1.0                       <pip>
mistune                   0.8.3                     <pip>
nbconvert                 5.3.1                     <pip>
nbformat                  4.4.0                     <pip>
ncurses                   6.0                  hd04f020_2  
notebook                  5.4.1                     <pip>
numpy                     1.14.2                    <pip>
openssl                   1.0.2o               h26aff7b_0  
pandas                    0.22.0                    <pip>
pandocfilters             1.4.2                     <pip>
parso                     0.2.0                     <pip>
pexpect                   4.5.0                     <pip>
pickleshare               0.7.4                     <pip>
pip                       9.0.3                    py36_0  
poyo                      0.4.1                     <pip>
prompt-toolkit            1.0.15                    <pip>
ptyprocess                0.5.2                     <pip>
Pygments                  2.2.0                     <pip>
python                    3.6.5                hc167b69_0  
python-dateutil           2.7.2                     <pip>
pytz                      2018.4                    <pip>
pyzmq                     17.0.0                    <pip>
readline                  7.0                  hc1231fa_4  
requests                  2.18.4                    <pip>
Send2Trash                1.5.0                     <pip>
setuptools                39.0.1                   py36_0  
simplegeneric             0.8.1                     <pip>
six                       1.11.0                    <pip>
sqlite                    3.22.0               h3efe00b_0  
terminado                 0.8.1                     <pip>
testpath                  0.3.1                     <pip>
tk                        8.6.7                h35a86e2_3  
tornado                   5.0.2                     <pip>
traitlets                 4.3.2                     <pip>
traittypes                0.0.6                     <pip>
urllib3                   1.22                      <pip>
wcwidth                   0.1.7                     <pip>
webencodings              0.5.1                     <pip>
wheel                     0.31.0                   py36_0  
whichcraft                0.4.1                     <pip>
widgetsnbextension        3.2.1                     <pip>
xz                        5.2.3                h0278029_2  
zlib                      1.2.11               hf3cbc9b_2  
@jasongrout
Copy link
Member

Thank you for the very comprehensive report. The root cause was tracked down at quantopian/qgrid#154. Basically, https://github.com/jupyter-widgets/widget-cookiecutter/blob/34b7db105520891dbbe4e1b25a08de89577df2f9/%7B%7Bcookiecutter.github_project_name%7D%7D/js/lib/index.js#L8 needs to be deleted - it's messing up the jupyterlab webpack config.

@jonmmease
Copy link
Author

Thanks for the help @jasongrout jupyter-widgets/widget-cookiecutter#37 removes this line and the associated comments

jonmmease pushed a commit to plotly/plotly.py that referenced this issue Apr 17, 2018
See jupyter-widgets/ipywidgets#2053

Install with
$ jupyter-labextension install js/
@vidartf
Copy link
Member

vidartf commented Apr 18, 2018

Note I did a follow up PR to the cookie-cutter to ensure that the classic extension still gets the public path set.

@github-actions github-actions bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 7, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

No branches or pull requests

3 participants