voila-dashboards / voila

Voilà turns Jupyter notebooks into standalone web applications
https://voila.readthedocs.io
Other
5.38k stars 500 forks source link

ipympl widget shows controls but no chart #1319

Open bsdz opened 1 year ago

bsdz commented 1 year ago

Description

I'm trying to create a matplotlib chart dynamically and display on click of widget button. The notebook works in jupyterlab and vscode when run normally (not within voila).

When I try running in voila the chart is displayed with only the controls.

image

Reproduce

Create notebook with following sample code:

%matplotlib widget

import ipywidgets as widgets
import matplotlib.pyplot as plt
import numpy as np

def create_figure():
    fig, ax = plt.subplots(nrows=1, ncols=1)
    np.random.seed(0)
    x = np.random.randn(1000)    
    ax.hist(x, 10)
    fig.tight_layout()
    return fig, ax

plt.ioff();

output = widgets.Output(layout={'border': '1px solid black'})

def action(b):
    with output:
        fig, ax = create_figure()
        display(fig.canvas)

button = widgets.Button(description="Create Figure 3")
button.on_click(action)
display(button, output)

Create a new python environment and install voila, ipympl, ipywidgets. I've made an effort to isolate the voila environment as much as possible from my other jupyter environment (why I've overridden various DIRs).

~$ cd /tmp
/tmp$ mkdir voila-test
/tmp$ cd voila-test/
/tmp/voila-test$ python3.10 -mvenv
/tmp/voila-test$ export JUPYTER_RUNTIME_DIR=/tmp/voila-test/.jupyter/runtime
/tmp/voila-test$ export JUPYTER_DATA_DIR=/tmp/voila-test/.jupyter/data
/tmp/voila-test$ export JUPYTER_CONFIG_DIR=/tmp/voila-test/.jupyter/config
/tmp/voila-test$ . .venv/bin/activate
(.venv) /tmp/voila-test$ pip install voila
(.venv) /tmp/voila-test$ pip install ipympl
(.venv) /tmp/voila-test$ pip install voila-material
(.venv) /tmp/voila-test$ pip install ipywidgets
(.venv) /tmp/voila-test$ voila --debug --enable_nbextensions=True --Voila.tornado_settings="{'allow_origin': '*'}" --template=material  --strip_sources=False ~/samples/ipympl_button.ipynb

Click the create figure button. A partial figure appears like screenshot above.

Expected behavior

Expect to see a chart like this appearing (this screenshot was taken from jupyterlab session).

image

Context

Troubleshoot Output
$PATH:
    /tmp/voila-test/.venv/bin
    ...
    /usr/local/sbin
    /usr/local/bin
    /usr/sbin
    /usr/bin
    /sbin
    /bin
    /usr/games
    /usr/local/games
    /snap/bin

sys.path:
    /tmp/voila-test/.venv/bin
    /usr/lib/python310.zip
    /usr/lib/python3.10
    /usr/lib/python3.10/lib-dynload
    /tmp/voila-test/.venv/lib/python3.10/site-packages

sys.executable:
    /tmp/voila-test/.venv/bin/python3.10

sys.version:
    3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]

platform.platform():
    Linux-5.15.0-69-generic-x86_64-with-glibc2.35

which -a jupyter:
    /tmp/voila-test/.venv/bin/jupyter

pip list:
    Package              Version
    -------------------- ---------
    anyio                3.6.2
    argon2-cffi          21.3.0
    argon2-cffi-bindings 21.2.0
    asttokens            2.2.1
    attrs                22.2.0
    Babel                2.12.1
    backcall             0.2.0
    beautifulsoup4       4.12.2
    bleach               6.0.0
    certifi              2022.12.7
    cffi                 1.15.1
    charset-normalizer   3.1.0
    comm                 0.1.3
    contourpy            1.0.7
    cycler               0.11.0
    debugpy              1.6.7
    decorator            5.1.1
    defusedxml           0.7.1
    entrypoints          0.4
    executing            1.2.0
    fastjsonschema       2.16.3
    fonttools            4.39.3
    idna                 3.4
    ipykernel            6.22.0
    ipympl               0.9.3
    ipython              8.12.0
    ipython-genutils     0.2.0
    ipywidgets           8.0.6
    jedi                 0.18.2
    Jinja2               3.1.2
    json5                0.9.11
    jsonschema           4.17.3
    jupyter_client       7.4.1
    jupyter_core         5.3.0
    jupyter-server       1.24.0
    jupyterlab-pygments  0.2.2
    jupyterlab_server    2.22.1
    jupyterlab-widgets   3.0.7
    kiwisolver           1.4.4
    MarkupSafe           2.1.2
    matplotlib           3.7.1
    matplotlib-inline    0.1.6
    mistune              2.0.5
    nbclient             0.7.3
    nbconvert            7.3.1
    nbformat             5.8.0
    nest-asyncio         1.5.6
    numpy                1.24.2
    packaging            23.1
    pandocfilters        1.5.0
    parso                0.8.3
    pexpect              4.8.0
    pickleshare          0.7.5
    Pillow               9.5.0
    pip                  22.0.2
    platformdirs         3.2.0
    prometheus-client    0.16.0
    prompt-toolkit       3.0.38
    psutil               5.9.4
    ptyprocess           0.7.0
    pure-eval            0.2.2
    pycparser            2.21
    Pygments             2.15.0
    pyparsing            3.0.9
    pyrsistent           0.19.3
    python-dateutil      2.8.2
    pyzmq                25.0.2
    requests             2.28.2
    Send2Trash           1.8.0
    setuptools           59.6.0
    six                  1.16.0
    sniffio              1.3.0
    soupsieve            2.4
    stack-data           0.6.2
    terminado            0.17.1
    tinycss2             1.2.1
    tornado              6.2
    traitlets            5.9.0
    urllib3              1.26.15
    voila                0.4.0
    voila-material       0.4.3
    wcwidth              0.2.6
    webencodings         0.5.1
    websocket-client     1.5.1
    websockets           11.0.1
    widgetsnbextension   4.0.7
Command Line Output
/tmp/voila-test/.venv/lib/python3.10/site-packages/traitlets/traitlets.py:3437: FutureWarning: --tornado_settings={'allow_origin': '*'} for dict-traits is deprecated in traitlets 5.0. You can pass --tornado_settings  ... multiple times to add items to a dict.
  warn(
[Voila] Looking for voila in /etc/jupyter
[Voila] Looking for voila in /usr/local/etc/jupyter
[Voila] Looking for voila in /tmp/voila-test/.jupyter/config
[Voila] Looking for voila in /tmp/voila-test/.venv/etc/jupyter
[Voila] Looking for voila in /tmp/voila-test
[Voila] using template: material
[Voila] template paths:
    /tmp/voila-test/.venv/share/jupyter/voila/templates/material
    /tmp/voila-test/.venv/share/jupyter/nbconvert/templates/material
    /tmp/voila-test/.venv/share/jupyter/voila/templates/lab
    /tmp/voila-test/.venv/share/jupyter/nbconvert/templates/lab
    /tmp/voila-test/.venv/share/jupyter/voila/templates/base
    /tmp/voila-test/.venv/share/jupyter/nbconvert/templates/base
    /tmp/voila-test/.venv/share/jupyter
    /tmp/voila-test/.venv/share/jupyter/voila/templates
    /tmp/voila-test/.venv/share/jupyter/nbconvert/templates
    /tmp/voila-test/.jupyter/data
    /tmp/voila-test/.jupyter/data/voila/templates
    /tmp/voila-test/.jupyter/data/nbconvert/templates
    /usr/local/share/jupyter
    /usr/local/share/jupyter/voila/templates
    /usr/local/share/jupyter/nbconvert/templates
    /usr/share/jupyter
    /usr/share/jupyter/voila/templates
    /usr/share/jupyter/nbconvert/templates
[Voila] static paths:
    /tmp/voila-test/.venv/share/jupyter/voila/templates/material/static
    /tmp/voila-test/.venv/share/jupyter/nbconvert/templates/material/static
    /tmp/voila-test/.jupyter/data/voila/templates/material/static
    /tmp/voila-test/.jupyter/data/nbconvert/templates/material/static
    /usr/local/share/jupyter/voila/templates/material/static
    /usr/local/share/jupyter/nbconvert/templates/material/static
    /usr/share/jupyter/voila/templates/material/static
    /usr/share/jupyter/nbconvert/templates/material/static
    /tmp/voila-test/.venv/share/jupyter/voila/templates/lab/static
    /tmp/voila-test/.venv/share/jupyter/nbconvert/templates/lab/static
    /tmp/voila-test/.jupyter/data/voila/templates/lab/static
    /tmp/voila-test/.jupyter/data/nbconvert/templates/lab/static
    /usr/local/share/jupyter/voila/templates/lab/static
    /usr/local/share/jupyter/nbconvert/templates/lab/static
    /usr/share/jupyter/voila/templates/lab/static
    /usr/share/jupyter/nbconvert/templates/lab/static
    /tmp/voila-test/.venv/share/jupyter/voila/templates/base/static
    /tmp/voila-test/.venv/share/jupyter/nbconvert/templates/base/static
    /tmp/voila-test/.jupyter/data/voila/templates/base/static
    /tmp/voila-test/.jupyter/data/nbconvert/templates/base/static
    /usr/local/share/jupyter/voila/templates/base/static
    /usr/local/share/jupyter/nbconvert/templates/base/static
    /usr/share/jupyter/voila/templates/base/static
    /usr/share/jupyter/nbconvert/templates/base/static
[Voila] Using /tmp to store connection files
[Voila] Storing connection files in /tmp/voila_i96h3xbn.
[Voila] Serving static files from /tmp/voila-test/.venv/lib/python3.10/site-packages/voila/static.
[Voila] Voilà is running at:
http://localhost:8866/
[Voila] Paths used for configuration of notebook: 
    /etc/jupyter/nbconfig/notebook.json
[Voila] Paths used for configuration of notebook: 
    /usr/local/etc/jupyter/nbconfig/notebook.json
[Voila] Paths used for configuration of notebook: 
    /tmp/voila-test/.jupyter/config/nbconfig/notebook.json
[Voila] Paths used for configuration of notebook: 
    /tmp/voila-test/.venv/etc/jupyter/nbconfig/notebook.d/jupyter-matplotlib.json
    /tmp/voila-test/.venv/etc/jupyter/nbconfig/notebook.d/voila.json
    /tmp/voila-test/.venv/etc/jupyter/nbconfig/notebook.d/widgetsnbextension.json
    /tmp/voila-test/.venv/etc/jupyter/nbconfig/notebook.json
[Voila] Paths used for configuration of notebook: 
    /etc/jupyter/serverconfig/notebook.json
[Voila] Paths used for configuration of notebook: 
    /usr/local/etc/jupyter/serverconfig/notebook.json
[Voila] Paths used for configuration of notebook: 
    /tmp/voila-test/.jupyter/config/serverconfig/notebook.json
[Voila] Paths used for configuration of notebook: 
    /tmp/voila-test/.venv/etc/jupyter/serverconfig/notebook.json
[Voila] WARNING | Notebook ipympl_button.ipynb is not trusted
[Voila] Found kernel python3 in /tmp/voila-test/.venv/share/jupyter/kernels
[Voila] Found kernel ir in /usr/share/jupyter/kernels
[Voila] Instantiating kernel 'Python 3 (ipykernel)' with kernel provisioner: local-provisioner
[Voila] Starting kernel: ['/tmp/voila-test/.venv/bin/python3.10', '-m', 'ipykernel_launcher', '-f', '/tmp/voila_i96h3xbn/kernel-22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38.json']
[Voila] Connecting to: tcp://127.0.0.1:37877
[Voila] Connecting to: tcp://127.0.0.1:49187
[Voila] Kernel started: 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] Kernel args: {'kernel_name': 'python3', 'env': {'SHELL': '/bin/bash', 'SESSION_MANAGER': 'local/mlrig:@/tmp/.ICE-unix/20449,unix/mlrig:/tmp/.ICE-unix/20449', 'QT_ACCESSIBILITY': '1', 'JUPYTER_CONFIG_DIR': '/tmp/voila-test/.jupyter/config', 'COLORTERM': 'truecolor', 'XDG_CONFIG_DIRS': '/etc/xdg/xdg-ubuntu:/etc/xdg', 'SSH_AGENT_LAUNCHER': 'gnome-keyring', 'XDG_MENU_PREFIX': 'gnome-', 'GNOME_DESKTOP_SESSION_ID': 'this-is-deprecated', 'LANGUAGE': 'en_GB:en', 'TERMINATOR_DBUS_PATH': '/net/tenshu/Terminator2', 'MANDATORY_PATH': '/usr/share/gconf/ubuntu.mandatory.path', 'GNOME_SHELL_SESSION_MODE': 'ubuntu', 'SSH_AUTH_SOCK': '/run/user/1000/keyring/ssh', 'TERMINATOR_UUID': 'urn:uuid:6fbd091b-f259-41f4-bef6-76b41f6a3eb2', 'XMODIFIERS': '@im=ibus', 'DESKTOP_SESSION': 'ubuntu', 'GTK_MODULES': 'gail:atk-bridge', 'PWD': '/tmp/voila-test', 'LOGNAME': 'blair', 'XDG_SESSION_DESKTOP': 'ubuntu', 'XDG_SESSION_TYPE': 'x11', 'GPG_AGENT_INFO': '/run/user/1000/gnupg/S.gpg-agent:0:1', 'SYSTEMD_EXEC_PID': '20449', 'XAUTHORITY': '/run/user/1000/gdm/Xauthority', 'WINDOWPATH': '2', 'HOME': '/home/blair', 'USERNAME': 'blair', 'IM_CONFIG_PHASE': '1', 'LANG': 'en_GB.UTF-8', 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:', 'XDG_CURRENT_DESKTOP': 'ubuntu:GNOME', 'VIRTUAL_ENV': '/tmp/voila-test/.venv', 'VTE_VERSION': '6800', 'PROMPT_COMMAND': 'history -a;history -n;', 'NLTK_DATA': '/home/blair/nltk_data', 'JUPYTER_DATA_DIR': '/tmp/voila-test/.jupyter/data', 'INVOCATION_ID': '98514d448585457c877c5849424c7039', 'TERMINATOR_DBUS_NAME': 'net.tenshu.Terminator23558193cd9818af7fe4d2c2f5bd9d00f', 'MANAGERPID': '8662', 'LESSCLOSE': '/usr/bin/lesspipe %s %s', 'XDG_SESSION_CLASS': 'user', 'JUPYTER_RUNTIME_DIR': '/tmp/voila-test/.jupyter/runtime', 'TERM': 'xterm-256color', 'DEFAULTS_PATH': '/usr/share/gconf/ubuntu.default.path', 'LESSOPEN': '| /usr/bin/lesspipe %s', 'LIBVIRT_DEFAULT_URI': 'qemu:///system', 'USER': 'blair', 'DISPLAY': ':1', 'SHLVL': '1', 'QT_IM_MODULE': 'ibus', 'DESKTOP_AUTOSTART_ID': '10845e45a38c013672168142348230336000000204490018', 'VIRTUAL_ENV_PROMPT': '(.venv) ', 'LD_LIBRARY_PATH': '/usr/local/cuda-10.1/lib64', 'XDG_RUNTIME_DIR': '/run/user/1000', 'PS1': '(.venv) \\[\\e]0;\\u@\\h: \\w\\a\\]${debian_chroot:+($debian_chroot)}\\[\\033[01;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ ', 'JOURNAL_STREAM': '8:223291', 'GTK3_MODULES': 'xapp-gtk3-module', 'XDG_DATA_DIRS': '/usr/share/ubuntu:/usr/share/gnome:/home/blair/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop', 'PATH': '/tmp/voila-test/.venv/bin:/home/blair/.cargo/bin:/home/blair/.poetry/bin:/home/blair/scripts:/home/blair/.local/bin:/home/blair/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin', 'GDMSESSION': 'ubuntu', 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus', 'GIO_LAUNCHED_DESKTOP_FILE_PID': '22192', 'GIO_LAUNCHED_DESKTOP_FILE': '/home/blair/.config/autostart/restart_jupyter_lab.sh.desktop', 'OLDPWD': '/tmp', '_': '/tmp/voila-test/.venv/bin/voila', 'PYDEVD_USE_FRAME_EVAL': 'NO', : '/', : '', : '', : 'voila/0.4.0', : 'HTTP/1.1', : '8866', : 'localhost', : 'False', : '/', : '/'}, 'cwd': '/home/blair/projects/dev-settings/pyenvs/voila-template/src/samples'}
[Voila] Template paths:
    /tmp/voila-test/.venv/share/jupyter/voila/templates/material
    /tmp/voila-test/.venv/share/jupyter/nbconvert/templates/material
    /tmp/voila-test/.venv/share/jupyter/voila/templates/lab
    /tmp/voila-test/.venv/share/jupyter/nbconvert/templates/lab
    /tmp/voila-test/.venv/share/jupyter/voila/templates/base
    /tmp/voila-test/.venv/share/jupyter/nbconvert/templates/base
    /tmp/voila-test/.venv/share/jupyter
    /tmp/voila-test/.venv/share/jupyter/voila/templates
    /tmp/voila-test/.venv/share/jupyter/nbconvert/templates
    /tmp/voila-test/.jupyter/data
    /tmp/voila-test/.jupyter/data/voila/templates
    /tmp/voila-test/.jupyter/data/nbconvert/templates
    /usr/local/share/jupyter
    /usr/local/share/jupyter/voila/templates
    /usr/local/share/jupyter/nbconvert/templates
    /usr/share/jupyter
    /usr/share/jupyter/voila/templates
    /usr/share/jupyter/nbconvert/templates
[Voila] Applying preprocessor: TagRemovePreprocessor
[Voila] Applying preprocessor: RegexRemovePreprocessor
[Voila] Applying preprocessor: coalesce_streams
[Voila] Applying preprocessor: HighlightMagicsPreprocessor
[Voila] Applying preprocessor: CSSHTMLHeaderPreprocessor
[Voila] Attempting to load template index.html.j2
[Voila]     template_paths: /tmp/voila-test/.venv/share/jupyter/voila/templates/material:/tmp/voila-test/.venv/share/jupyter/nbconvert/templates/material:/tmp/voila-test/.venv/share/jupyter/voila/templates/lab:/tmp/voila-test/.venv/share/jupyter/nbconvert/templates/lab:/tmp/voila-test/.venv/share/jupyter/voila/templates/base:/tmp/voila-test/.venv/share/jupyter/nbconvert/templates/base:/tmp/voila-test/.venv/share/jupyter:/tmp/voila-test/.venv/share/jupyter/voila/templates:/tmp/voila-test/.venv/share/jupyter/nbconvert/templates:/tmp/voila-test/.jupyter/data:/tmp/voila-test/.jupyter/data/voila/templates:/tmp/voila-test/.jupyter/data/nbconvert/templates:/usr/local/share/jupyter:/usr/local/share/jupyter/voila/templates:/usr/local/share/jupyter/nbconvert/templates:/usr/share/jupyter:/usr/share/jupyter/voila/templates:/usr/share/jupyter/nbconvert/templates
[Voila] connecting iopub channel to tcp://127.0.0.1:49187
[Voila] Connecting to: tcp://127.0.0.1:49187
[Voila] connecting shell channel to tcp://127.0.0.1:42129
[Voila] Connecting to: tcp://127.0.0.1:42129
[Voila] connecting stdin channel to tcp://127.0.0.1:54999
[Voila] Connecting to: tcp://127.0.0.1:54999
[Voila] connecting heartbeat channel to tcp://127.0.0.1:37213
[Voila] connecting control channel to tcp://127.0.0.1:37877
[Voila] Connecting to: tcp://127.0.0.1:37877
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] Executing cell:
%matplotlib widget

import ipywidgets as widgets
import matplotlib.pyplot as plt
import numpy as np

def create_figure():
    fig, ax = plt.subplots(nrows=1, ncols=1)
    np.random.seed(0)
    x = np.random.randn(1000)    
    ax.hist(x, 10)
    fig.tight_layout()
    return fig, ax

plt.ioff();

output = widgets.Output(layout={'border': '1px solid black'})

def action(b):
    with output:
        fig, ax = create_figure()
        display(fig.canvas)

button = widgets.Button(description="Create Figure 3")
button.on_click(action)
display(button, output)

[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: execute_input
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: execute_input
[Voila] msg_type: status
[Voila] content: {'execution_state': 'busy'}
[Voila] msg_type: execute_input
[Voila] content: {'code': '%matplotlib widget\n\nimport ipywidgets as widgets\nimport matplotlib.pyplot as plt\nimport numpy as np\n\ndef create_figure():\n    fig, ax = plt.subplots(nrows=1, ncols=1)\n    np.random.seed(0)\n    x = np.random.randn(1000)    \n    ax.hist(x, 10)\n    fig.tight_layout()\n    return fig, ax\n\nplt.ioff();\n\noutput = widgets.Output(layout={\'border\': \'1px solid black\'})\n\ndef action(b):\n    with output:\n        fig, ax = create_figure()\n        display(fig.canvas)\n\nbutton = widgets.Button(description="Create Figure 3")\nbutton.on_click(action)\ndisplay(button, output)\n', 'execution_count': 1}
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_open
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_open
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_open
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_open
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_open
[Voila] msg_type: comm_open
[Voila] content: {'data': {'state': {'_model_module': '@jupyter-widgets/base', '_model_module_version': '2.0.0', '_model_name': 'LayoutModel', '_view_count': None, '_view_module': '@jupyter-widgets/base', '_view_module_version': '2.0.0', '_view_name': 'LayoutView', 'align_content': None, 'align_items': None, 'align_self': None, 'border_bottom': '1px solid black', 'border_left': '1px solid black', 'border_right': '1px solid black', 'border_top': '1px solid black', 'bottom': None, 'display': None, 'flex': None, 'flex_flow': None, 'grid_area': None, 'grid_auto_columns': None, 'grid_auto_flow': None, 'grid_auto_rows': None, 'grid_column': None, 'grid_gap': None, 'grid_row': None, 'grid_template_areas': None, 'grid_template_columns': None, 'grid_template_rows': None, 'height': None, 'justify_content': None, 'justify_items': None, 'left': None, 'margin': None, 'max_height': None, 'max_width': None, 'min_height': None, 'min_width': None, 'object_fit': None, 'object_position': None, 'order': None, 'overflow': None, 'padding': None, 'right': None, 'top': None, 'visibility': None, 'width': None}, 'buffer_paths': []}, 'comm_id': 'fab34145844e4545b1e716957700b021', 'target_name': 'jupyter.widget', 'target_module': None}
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: display_data
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: display_data
[Voila] msg_type: comm_open
[Voila] content: {'data': {'state': {'_dom_classes': [], '_model_module': '@jupyter-widgets/output', '_model_module_version': '1.0.0', '_model_name': 'OutputModel', '_view_count': None, '_view_module': '@jupyter-widgets/output', '_view_module_version': '1.0.0', '_view_name': 'OutputView', 'layout': 'IPY_MODEL_fab34145844e4545b1e716957700b021', 'msg_id': '', 'outputs': [], 'tabbable': None, 'tooltip': None}, 'buffer_paths': []}, 'comm_id': 'dd1cf7003b424b73a8cfbe6eaacce085', 'target_name': 'jupyter.widget', 'target_module': None}
[Voila] msg_type: comm_open
[Voila] content: {'data': {'state': {'_model_module': '@jupyter-widgets/base', '_model_module_version': '2.0.0', '_model_name': 'LayoutModel', '_view_count': None, '_view_module': '@jupyter-widgets/base', '_view_module_version': '2.0.0', '_view_name': 'LayoutView', 'align_content': None, 'align_items': None, 'align_self': None, 'border_bottom': None, 'border_left': None, 'border_right': None, 'border_top': None, 'bottom': None, 'display': None, 'flex': None, 'flex_flow': None, 'grid_area': None, 'grid_auto_columns': None, 'grid_auto_flow': None, 'grid_auto_rows': None, 'grid_column': None, 'grid_gap': None, 'grid_row': None, 'grid_template_areas': None, 'grid_template_columns': None, 'grid_template_rows': None, 'height': None, 'justify_content': None, 'justify_items': None, 'left': None, 'margin': None, 'max_height': None, 'max_width': None, 'min_height': None, 'min_width': None, 'object_fit': None, 'object_position': None, 'order': None, 'overflow': None, 'padding': None, 'right': None, 'top': None, 'visibility': None, 'width': None}, 'buffer_paths': []}, 'comm_id': '5d03742f9d474d1f9835ea4e00167bca', 'target_name': 'jupyter.widget', 'target_module': None}
[Voila] msg_type: comm_open
[Voila] content: {'data': {'state': {'_model_module': '@jupyter-widgets/controls', '_model_module_version': '2.0.0', '_model_name': 'ButtonStyleModel', '_view_count': None, '_view_module': '@jupyter-widgets/base', '_view_module_version': '2.0.0', '_view_name': 'StyleView', 'button_color': None, 'font_family': None, 'font_size': None, 'font_style': None, 'font_variant': None, 'font_weight': None, 'text_color': None, 'text_decoration': None}, 'buffer_paths': []}, 'comm_id': '7bfabfd6fb284efc8d18c7797a5517f9', 'target_name': 'jupyter.widget', 'target_module': None}
[Voila] msg_type: comm_open
[Voila] content: {'data': {'state': {'_dom_classes': [], '_model_module': '@jupyter-widgets/controls', '_model_module_version': '2.0.0', '_model_name': 'ButtonModel', '_view_count': None, '_view_module': '@jupyter-widgets/controls', '_view_module_version': '2.0.0', '_view_name': 'ButtonView', 'button_style': '', 'description': 'Create Figure 3', 'disabled': False, 'icon': '', 'layout': 'IPY_MODEL_5d03742f9d474d1f9835ea4e00167bca', 'style': 'IPY_MODEL_7bfabfd6fb284efc8d18c7797a5517f9', 'tabbable': None, 'tooltip': None}, 'buffer_paths': []}, 'comm_id': '0ba146f43f704e09a7f7cffa8c4a5431', 'target_name': 'jupyter.widget', 'target_module': None}
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] msg_type: display_data
[Voila] content: {'data': {'text/plain': "Button(description='Create Figure 3', style=ButtonStyle())", 'application/vnd.jupyter.widget-view+json': {'version_major': 2, 'version_minor': 0, 'model_id': '0ba146f43f704e09a7f7cffa8c4a5431'}}, 'metadata': {}, 'transient': {}}
[Voila] msg_type: display_data
[Voila] content: {'data': {'text/plain': "Output(layout=Layout(border_bottom='1px solid black', border_left='1px solid black', border_right='1px solid b…", 'application/vnd.jupyter.widget-view+json': {'version_major': 2, 'version_minor': 0, 'model_id': 'dd1cf7003b424b73a8cfbe6eaacce085'}}, 'metadata': {}, 'transient': {}}
[Voila] msg_type: status
[Voila] content: {'execution_state': 'idle'}
[Voila] Skipping non-executing cell 1
[Voila] Path jupyter-matplotlib/extension.js served from /tmp/voila-test/.venv/share/jupyter/nbextensions/jupyter-matplotlib/extension.js
/tmp/voila-test/.venv/lib/python3.10/site-packages/jupyter_server/base/handlers.py:197: UserWarning: The Tornado web application does not have an 'authorizer' defined in its settings. In future releases of jupyter_server, this will be a required key for all subclasses of `JupyterHandler`. For an example, see the jupyter_server source code for how to add an authorizer to the tornado settings: https://github.com/jupyter-server/jupyter_server/blob/653740cbad7ce0c8a8752ce83e4d3c2c754b13cb/jupyter_server/serverapp.py#L234-L256
  warnings.warn(
[Voila] Initializing websocket connection /api/kernels/22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38/channels
[Voila] Requesting kernel info from 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] Connecting to: tcp://127.0.0.1:42129
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] Received kernel info: {'status': 'ok', 'protocol_version': '5.3', 'implementation': 'ipython', 'implementation_version': '8.12.0', 'language_info': {'name': 'python', 'version': '3.10.6', 'mimetype': 'text/x-python', 'codemirror_mode': {'name': 'ipython', 'version': 3}, 'pygments_lexer': 'ipython3', 'nbconvert_exporter': 'python', 'file_extension': '.py'}, 'banner': "Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]\nType 'copyright', 'credits' or 'license' for more information\nIPython 8.12.0 -- An enhanced Interactive Python. Type '?' for help.\n", 'help_links': [{'text': 'Python Reference', 'url': 'https://docs.python.org/3.10'}, {'text': 'IPython Reference', 'url': 'https://ipython.org/documentation.html'}, {'text': 'NumPy Reference', 'url': 'https://docs.scipy.org/doc/numpy/reference/'}, {'text': 'SciPy Reference', 'url': 'https://docs.scipy.org/doc/scipy/reference/'}, {'text': 'Matplotlib Reference', 'url': 'https://matplotlib.org/contents.html'}, {'text': 'SymPy Reference', 'url': 'http://docs.sympy.org/latest/index.html'}, {'text': 'pandas Reference', 'url': 'https://pandas.pydata.org/pandas-docs/stable/'}]}
[Voila] Opening websocket /api/kernels/22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38/channels
[Voila] Getting buffer for 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] Connecting to: tcp://127.0.0.1:49187
[Voila] Connecting to: tcp://127.0.0.1:42129
[Voila] Connecting to: tcp://127.0.0.1:37877
[Voila] Connecting to: tcp://127.0.0.1:54999
[Voila] Connecting to: tcp://127.0.0.1:42129
[Voila] Connecting to: tcp://127.0.0.1:37877
[Voila] Nudge: attempt 1 on kernel 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] Nudge: IOPub received: 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] Nudge: resolving iopub future: 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] Nudge: control info reply received: 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] Nudge: resolving control future: 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] Initializing websocket connection /api/kernels/22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38/channels
[Voila] Opening websocket /api/kernels/22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38/channels
[Voila] Getting buffer for 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] Connecting to: tcp://127.0.0.1:49187
[Voila] Connecting to: tcp://127.0.0.1:42129
[Voila] Connecting to: tcp://127.0.0.1:37877
[Voila] Connecting to: tcp://127.0.0.1:54999
[Voila] Connecting to: tcp://127.0.0.1:42129
[Voila] Connecting to: tcp://127.0.0.1:37877
[Voila] Nudge: IOPub received: 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] Nudge: resolving iopub future: 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] Nudge: attempt 1 on kernel 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
403 GET /voila/files/favicon.ico (127.0.0.1): File not whitelisted
403 GET /voila/files/favicon.ico (127.0.0.1) 3.14ms
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] Nudge: control info reply received: 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] Nudge: resolving control future: 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] Nudge: shell info reply received: 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_msg
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_msg
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_open
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_open
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_open
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_open
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_msg
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_msg
[Voila] Path jupyter-matplotlib/index.js served from /tmp/voila-test/.venv/share/jupyter/nbextensions/jupyter-matplotlib/index.js
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_msg
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_msg
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_msg
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: display_data
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_msg
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_msg
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_msg
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_msg
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: stream
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: stream
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: comm_msg
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (busy)
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: stream
[Voila] activity on 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38: status (idle)
^C[Voila] Stopping...
[Voila] Clearing buffer for 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] Kernel shutdown: 22ecb5db-6cf8-4c1f-bb6b-1ff75b23fb38
[Voila] Connecting to: tcp://127.0.0.1:37877
[Voila] Destroying zmq context for 

Browser Output
Loaded classic notebook extension "jupyter-matplotlib/extension".
(index):45 Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438
console.error @ (index):45
(anonymous) @ yjs.mjs:9771
i @ bootstrap:63
(anonymous) @ voila.js?v=8db1cadbfba43a6dfc2d64128318e696bcb26b1783db1b991faf7404d438cd53200b6c434c4897064c090b68aa1151cd96c6dab50c3e138553365e6b30889172:472
i @ bootstrap:63
(anonymous) @ voila.js?v=8db1cadbfba43a6dfc2d64128318e696bcb26b1783db1b991faf7404d438cd53200b6c434c4897064c090b68aa1151cd96c6dab50c3e138553365e6b30889172:472
i @ bootstrap:63
(anonymous) @ voila.js?v=8db1cadbfba43a6dfc2d64128318e696bcb26b1783db1b991faf7404d438cd53200b6c434c4897064c090b68aa1151cd96c6dab50c3e138553365e6b30889172:61
i @ bootstrap:63
(anonymous) @ voila.js?v=8db1cadbfba43a6dfc2d64128318e696bcb26b1783db1b991faf7404d438cd53200b6c434c4897064c090b68aa1151cd96c6dab50c3e138553365e6b30889172:61
i @ bootstrap:63
(anonymous) @ voila.js?v=8db1cadbfba43a6dfc2d64128318e696bcb26b1783db1b991faf7404d438cd53200b6c434c4897064c090b68aa1151cd96c6dab50c3e138553365e6b30889172:458
i @ bootstrap:63
(anonymous) @ voila.js?v=8db1cadbfba43a6dfc2d64128318e696bcb26b1783db1b991faf7404d438cd53200b6c434c4897064c090b68aa1151cd96c6dab50c3e138553365e6b30889172:398
i @ bootstrap:63
(anonymous) @ bootstrap:198
(anonymous) @ voila.js?v=8db1cadbfba43a6dfc2d64128318e696bcb26b1783db1b991faf7404d438cd53200b6c434c4897064c090b68aa1151cd96c6dab50c3e138553365e6b30889172:1
execCb @ require.min.js:1
check @ require.min.js:1
enable @ require.min.js:1
init @ require.min.js:1
h @ require.min.js:1
completeLoad @ require.min.js:1
onScriptLoad @ require.min.js:1
load (async)
req.load @ require.min.js:1
load @ require.min.js:1
load @ require.min.js:1
fetch @ require.min.js:1
check @ require.min.js:1
enable @ require.min.js:1
enable @ require.min.js:1
(anonymous) @ require.min.js:1
(anonymous) @ require.min.js:1
each @ require.min.js:1
enable @ require.min.js:1
init @ require.min.js:1
(anonymous) @ require.min.js:1
setTimeout (async)
req.nextTick @ require.min.js:1
o @ require.min.js:1
requirejs @ require.min.js:1
(anonymous) @ main.js?v=07cc494763c3dcb3b604da7aa291ed361b8b163d9cb33c4bc3a66304c18e1dc5bfcf8c6101b6b6426ab36762a01a8568e9f3bf0c7ba6588cd61eab538b95e34a:10
favicon.ico:1     GET http://localhost:8866/voila/files/favicon.ico 403 (Forbidden)
4(index):45 Exception opening new comm
console.error @ (index):45
_handleCommOpen @ default.js:1101
await in _handleCommOpen (async)
_handleMessage @ default.js:1263
(anonymous) @ default.js:162
Promise.then (async)
_onWSMessage @ default.js:159
bsdz commented 1 year ago

I've just tried installing voila from the main branch here and this appears to resolve the issue. I should have tried that earlier on. Is a 0.5.0 release with the most recent changes pending? I tried 0.5.0a3 via pypi but this shows javascript errors where the buttons are.