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

HTML widget not rendering in nbconvert --to html (only renders source) #3713

Open
munro opened this issue Mar 3, 2023 · 0 comments
Open

Comments

@munro
Copy link

munro commented Mar 3, 2023

Description

When I render a notebook with nbconvert --execute --to html — HTML widgets don't render, they only show source!

Widgets like VBox / Accordion / Label / Text work though!

python -m nbconvert --execute --to html hello.ipynb
open hello.html

image

Reproduce

1. setup env

conda create -n ipywidgets-test --override-channels --strict-channel-priority -c conda-forge -c anaconda jupyterlab
conda activate ipywidgets-test
pip install nbconvert ipywidgets
pip install --upgrade ipywidgets

2. create hello.ipynb with cell data

from IPython.display import display, HTML

display(HTML("<h1>IPython.display.html WORKS</h1>"))
import ipywidgets as widgets

print(widgets.__version__)

out = widgets.Output()
with out:

    display(HTML("<h1>widgets.Output(IPython.display.html) DOESN'T WORK</h1>"))
    display(widgets.HTML("<h1>widgets.Output(widgets.HTML) DOESN'T WORK</h1>"))


display(widgets.HTML("<h2>widgets.HTML DOESN'T WORK</h2>"))

widgets.VBox([out, out, widgets.HTML("<h2>VBox(widgets.HTML) DOESN'T WORK</h3>")])

3. run nbconvert

python -m nbconvert --execute --to html hello.ipynb

4. view in browser

open hello.html

Expected behavior

It works fine in jupyter lab & vscode notebooks!!

image

Context

  • ipywidgets version 8.0.4
  • Operating System and version: macOS Ventura 13.2.1 (22D68)
  • Browser and version: Firefox (also happened in Chrome)
Troubleshoot Output
sys.version:
	3.11.0 | packaged by conda-forge | (main, Jan 14 2023, 12:26:40) [Clang 14.0.6 ]

pip list:
Package Version
----------------------------- -----------
anyio 3.6.2
appnope 0.1.3
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
backports.functools-lru-cache 1.6.4
beautifulsoup4 4.11.2
bleach 6.0.0
brotlipy 0.7.0
certifi 2022.12.7
cffi 1.15.1
charset-normalizer 2.1.1
comm 0.1.2
cryptography 39.0.2
debugpy 1.6.6
decorator 5.1.1
defusedxml 0.7.1
entrypoints 0.4
executing 1.2.0
fastjsonschema 2.16.3
flit_core 3.8.0
idna 3.4
importlib-metadata 6.0.0
importlib-resources 5.12.0
ipykernel 6.21.2
ipython 8.11.0
ipython-genutils 0.2.0
ipywidgets 8.0.4
jedi 0.18.2
Jinja2 3.1.2
json5 0.9.5
jsonschema 4.17.3
jupyter_client 8.0.3
jupyter_core 5.2.0
jupyter-events 0.6.3
jupyter_server 2.3.0
jupyter_server_terminals 0.4.4
jupyterlab 3.5.0
jupyterlab-pygments 0.2.2
jupyterlab_server 2.19.0
jupyterlab-widgets 3.0.5
MarkupSafe 2.1.2
matplotlib-inline 0.1.6
mistune 2.0.5
nbclassic 0.5.2
nbclient 0.7.2
nbconvert 7.2.9
nbformat 5.7.3
nest-asyncio 1.5.6
notebook 6.5.2
notebook_shim 0.2.2
packaging 23.0
pandocfilters 1.5.0
parso 0.8.3
pexpect 4.8.0
pickleshare 0.7.5
pip 23.0.1
pkgutil_resolve_name 1.3.10
platformdirs 3.0.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.14.0
pyOpenSSL 23.0.0
pyrsistent 0.19.3
PySocks 1.7.1
python-dateutil 2.8.2
python-json-logger 2.0.7
pytz 2022.7.1
PyYAML 6.0
pyzmq 25.0.0
requests 2.28.2
rfc3339-validator 0.1.4
rfc3986-validator 0.1.1
Send2Trash 1.8.0
setuptools 67.4.0
six 1.16.0
sniffio 1.3.0
soupsieve 2.3.2.post1
stack-data 0.6.2
terminado 0.17.1
tinycss2 1.2.1
tomli 2.0.1
tornado 6.2
traitlets 5.9.0
typing_extensions 4.4.0
urllib3 1.26.14
wcwidth 0.2.6
webencodings 0.5.1
websocket-client 1.5.1
wheel 0.38.4
widgetsnbextension 4.0.5
zipp 3.15.0

conda list:
# packages in environment at /opt/homebrew/Caskroom/miniconda/base/envs/ipywidgets-test:
#
# Name Version Build Channel
anyio 3.6.2 pyhd8ed1ab_0 conda-forge
appnope 0.1.3 pyhd8ed1ab_0 conda-forge
argon2-cffi 21.3.0 pyhd8ed1ab_0 conda-forge
argon2-cffi-bindings 21.2.0 py311he2be06e_3 conda-forge
asttokens 2.2.1 pyhd8ed1ab_0 conda-forge
attrs 22.2.0 pyh71513ae_0 conda-forge
babel 2.12.1 pyhd8ed1ab_1 conda-forge
backcall 0.2.0 pyh9f0ad1d_0 conda-forge
backports 1.0 pyhd8ed1ab_3 conda-forge
backports.functools_lru_cache 1.6.4 pyhd8ed1ab_0 conda-forge
beautifulsoup4 4.11.2 pyha770c72_0 conda-forge
bleach 6.0.0 pyhd8ed1ab_0 conda-forge
brotlipy 0.7.0 py311he2be06e_1005 conda-forge
bzip2 1.0.8 h3422bc3_4 conda-forge
ca-certificates 2022.12.7 h4653dfc_0 conda-forge
certifi 2022.12.7 pyhd8ed1ab_0 conda-forge
cffi 1.15.1 py311hae827db_3 conda-forge
charset-normalizer 2.1.1 pyhd8ed1ab_0 conda-forge
comm 0.1.2 pyhd8ed1ab_0 conda-forge
cryptography 39.0.2 py311h507f6e9_0 conda-forge
debugpy 1.6.6 py311ha397e9f_0 conda-forge
decorator 5.1.1 pyhd8ed1ab_0 conda-forge
defusedxml 0.7.1 pyhd8ed1ab_0 conda-forge
entrypoints 0.4 pyhd8ed1ab_0 conda-forge
executing 1.2.0 pyhd8ed1ab_0 conda-forge
flit-core 3.8.0 pyhd8ed1ab_0 conda-forge
idna 3.4 pyhd8ed1ab_0 conda-forge
importlib-metadata 6.0.0 pyha770c72_0 conda-forge
importlib_metadata 6.0.0 hd8ed1ab_0 conda-forge
importlib_resources 5.12.0 pyhd8ed1ab_0 conda-forge
ipykernel 6.21.2 pyh736e0ef_0 conda-forge
ipython 8.11.0 pyhd1c38e8_0 conda-forge
ipython_genutils 0.2.0 py_1 conda-forge
ipywidgets 8.0.4 pypi_0 pypi
jedi 0.18.2 pyhd8ed1ab_0 conda-forge
jinja2 3.1.2 pyhd8ed1ab_1 conda-forge
json5 0.9.5 pyh9f0ad1d_0 conda-forge
jsonschema 4.17.3 pyhd8ed1ab_0 conda-forge
jupyter_client 8.0.3 pyhd8ed1ab_0 conda-forge
jupyter_core 5.2.0 py311h267d04e_0 conda-forge
jupyter_events 0.6.3 pyhd8ed1ab_0 conda-forge
jupyter_server 2.3.0 pyhd8ed1ab_0 conda-forge
jupyter_server_terminals 0.4.4 pyhd8ed1ab_1 conda-forge
jupyterlab 3.5.0 pyhd8ed1ab_0 conda-forge
jupyterlab-widgets 3.0.5 pypi_0 pypi
jupyterlab_pygments 0.2.2 pyhd8ed1ab_0 conda-forge
jupyterlab_server 2.19.0 pyhd8ed1ab_0 conda-forge
libcxx 15.0.7 h75e25f2_0 conda-forge
libffi 3.4.2 h3422bc3_5 conda-forge
libsodium 1.0.18 h27ca646_1 conda-forge
libsqlite 3.40.0 h76d750c_0 conda-forge
libzlib 1.2.13 h03a7124_4 conda-forge
markupsafe 2.1.2 py311he2be06e_0 conda-forge
matplotlib-inline 0.1.6 pyhd8ed1ab_0 conda-forge
mistune 2.0.5 pyhd8ed1ab_0 conda-forge
nbclassic 0.5.2 pyhd8ed1ab_0 conda-forge
nbclient 0.7.2 pyhd8ed1ab_0 conda-forge
nbconvert 7.2.9 pyhd8ed1ab_0 conda-forge
nbconvert-core 7.2.9 pyhd8ed1ab_0 conda-forge
nbconvert-pandoc 7.2.9 pyhd8ed1ab_0 conda-forge
nbformat 5.7.3 pyhd8ed1ab_0 conda-forge
ncurses 6.3 h07bb92c_1 conda-forge
nest-asyncio 1.5.6 pyhd8ed1ab_0 conda-forge
notebook 6.5.2 pyha770c72_1 conda-forge
notebook-shim 0.2.2 pyhd8ed1ab_0 conda-forge
openssl 3.0.8 h03a7124_0 conda-forge
packaging 23.0 pyhd8ed1ab_0 conda-forge
pandoc 2.19.2 hce30654_1 conda-forge
pandocfilters 1.5.0 pyhd8ed1ab_0 conda-forge
parso 0.8.3 pyhd8ed1ab_0 conda-forge
pexpect 4.8.0 pyh1a96a4e_2 conda-forge
pickleshare 0.7.5 py_1003 conda-forge
pip 23.0.1 pyhd8ed1ab_0 conda-forge
pkgutil-resolve-name 1.3.10 pyhd8ed1ab_0 conda-forge
platformdirs 3.0.0 pyhd8ed1ab_0 conda-forge
prometheus_client 0.16.0 pyhd8ed1ab_0 conda-forge
prompt-toolkit 3.0.38 pyha770c72_0 conda-forge
prompt_toolkit 3.0.38 hd8ed1ab_0 conda-forge
psutil 5.9.4 py311he2be06e_0 conda-forge
ptyprocess 0.7.0 pyhd3deb0d_0 conda-forge
pure_eval 0.2.2 pyhd8ed1ab_0 conda-forge
pycparser 2.21 pyhd8ed1ab_0 conda-forge
pygments 2.14.0 pyhd8ed1ab_0 conda-forge
pyopenssl 23.0.0 pyhd8ed1ab_0 conda-forge
pyrsistent 0.19.3 py311he2be06e_0 conda-forge
pysocks 1.7.1 pyha2e5f31_6 conda-forge
python 3.11.0 h3ba56d0_1_cpython conda-forge
python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge
python-fastjsonschema 2.16.3 pyhd8ed1ab_0 conda-forge
python-json-logger 2.0.7 pyhd8ed1ab_0 conda-forge
python_abi 3.11 3_cp311 conda-forge
pytz 2022.7.1 pyhd8ed1ab_0 conda-forge
pyyaml 6.0 py311he2be06e_5 conda-forge
pyzmq 25.0.0 py311h0f351f6_0 conda-forge
readline 8.1.2 h46ed386_0 conda-forge
requests 2.28.2 pyhd8ed1ab_0 conda-forge
rfc3339-validator 0.1.4 pyhd8ed1ab_0 conda-forge
rfc3986-validator 0.1.1 pyh9f0ad1d_0 conda-forge
send2trash 1.8.0 pyhd8ed1ab_0 conda-forge
setuptools 67.4.0 pyhd8ed1ab_0 conda-forge
six 1.16.0 pyh6c4a22f_0 conda-forge
sniffio 1.3.0 pyhd8ed1ab_0 conda-forge
soupsieve 2.3.2.post1 pyhd8ed1ab_0 conda-forge
stack_data 0.6.2 pyhd8ed1ab_0 conda-forge
terminado 0.17.1 pyhd1c38e8_0 conda-forge
tinycss2 1.2.1 pyhd8ed1ab_0 conda-forge
tk 8.6.12 he1e0b03_0 conda-forge
tomli 2.0.1 pyhd8ed1ab_0 conda-forge
tornado 6.2 py311he2be06e_1 conda-forge
traitlets 5.9.0 pyhd8ed1ab_0 conda-forge
typing-extensions 4.4.0 hd8ed1ab_0 conda-forge
typing_extensions 4.4.0 pyha770c72_0 conda-forge
tzdata 2022g h191b570_0 conda-forge
urllib3 1.26.14 pyhd8ed1ab_0 conda-forge
wcwidth 0.2.6 pyhd8ed1ab_0 conda-forge
webencodings 0.5.1 py_1 conda-forge
websocket-client 1.5.1 pyhd8ed1ab_0 conda-forge
wheel 0.38.4 pyhd8ed1ab_0 conda-forge
widgetsnbextension 4.0.5 pypi_0 pypi
xz 5.2.6 h57fd34a_0 conda-forge
yaml 0.2.5 h3422bc3_2 conda-forge
zeromq 4.3.4 hbdafb3b_1 conda-forge
zipp 3.15.0 pyhd8ed1ab_0 conda-forge

conda env:
name: ipywidgets-test
channels:
- conda-forge
- defaults
dependencies:
- anyio=3.6.2=pyhd8ed1ab_0
- appnope=0.1.3=pyhd8ed1ab_0
- argon2-cffi=21.3.0=pyhd8ed1ab_0
- argon2-cffi-bindings=21.2.0=py311he2be06e_3
- asttokens=2.2.1=pyhd8ed1ab_0
- attrs=22.2.0=pyh71513ae_0
- babel=2.12.1=pyhd8ed1ab_1
- backcall=0.2.0=pyh9f0ad1d_0
- backports=1.0=pyhd8ed1ab_3
- backports.functools_lru_cache=1.6.4=pyhd8ed1ab_0
- beautifulsoup4=4.11.2=pyha770c72_0
- bleach=6.0.0=pyhd8ed1ab_0
- brotlipy=0.7.0=py311he2be06e_1005
- bzip2=1.0.8=h3422bc3_4
- ca-certificates=2022.12.7=h4653dfc_0
- certifi=2022.12.7=pyhd8ed1ab_0
- cffi=1.15.1=py311hae827db_3
- charset-normalizer=2.1.1=pyhd8ed1ab_0
- comm=0.1.2=pyhd8ed1ab_0
- cryptography=39.0.2=py311h507f6e9_0
- debugpy=1.6.6=py311ha397e9f_0
- decorator=5.1.1=pyhd8ed1ab_0
- defusedxml=0.7.1=pyhd8ed1ab_0
- entrypoints=0.4=pyhd8ed1ab_0
- executing=1.2.0=pyhd8ed1ab_0
- flit-core=3.8.0=pyhd8ed1ab_0
- idna=3.4=pyhd8ed1ab_0
- importlib-metadata=6.0.0=pyha770c72_0
- importlib_metadata=6.0.0=hd8ed1ab_0
- importlib_resources=5.12.0=pyhd8ed1ab_0
- ipykernel=6.21.2=pyh736e0ef_0
- ipython=8.11.0=pyhd1c38e8_0
- ipython_genutils=0.2.0=py_1
- jedi=0.18.2=pyhd8ed1ab_0
- jinja2=3.1.2=pyhd8ed1ab_1
- json5=0.9.5=pyh9f0ad1d_0
- jsonschema=4.17.3=pyhd8ed1ab_0
- jupyter_client=8.0.3=pyhd8ed1ab_0
- jupyter_core=5.2.0=py311h267d04e_0
- jupyter_events=0.6.3=pyhd8ed1ab_0
- jupyter_server=2.3.0=pyhd8ed1ab_0
- jupyter_server_terminals=0.4.4=pyhd8ed1ab_1
- jupyterlab=3.5.0=pyhd8ed1ab_0
- jupyterlab_pygments=0.2.2=pyhd8ed1ab_0
- jupyterlab_server=2.19.0=pyhd8ed1ab_0
- libcxx=15.0.7=h75e25f2_0
- libffi=3.4.2=h3422bc3_5
- libsodium=1.0.18=h27ca646_1
- libsqlite=3.40.0=h76d750c_0
- libzlib=1.2.13=h03a7124_4
- markupsafe=2.1.2=py311he2be06e_0
- matplotlib-inline=0.1.6=pyhd8ed1ab_0
- mistune=2.0.5=pyhd8ed1ab_0
- nbclassic=0.5.2=pyhd8ed1ab_0
- nbclient=0.7.2=pyhd8ed1ab_0
- nbconvert=7.2.9=pyhd8ed1ab_0
- nbconvert-core=7.2.9=pyhd8ed1ab_0
- nbconvert-pandoc=7.2.9=pyhd8ed1ab_0
- nbformat=5.7.3=pyhd8ed1ab_0
- ncurses=6.3=h07bb92c_1
- nest-asyncio=1.5.6=pyhd8ed1ab_0
- notebook=6.5.2=pyha770c72_1
- notebook-shim=0.2.2=pyhd8ed1ab_0
- openssl=3.0.8=h03a7124_0
- packaging=23.0=pyhd8ed1ab_0
- pandoc=2.19.2=hce30654_1
- pandocfilters=1.5.0=pyhd8ed1ab_0
- parso=0.8.3=pyhd8ed1ab_0
- pexpect=4.8.0=pyh1a96a4e_2
- pickleshare=0.7.5=py_1003
- pip=23.0.1=pyhd8ed1ab_0
- pkgutil-resolve-name=1.3.10=pyhd8ed1ab_0
- platformdirs=3.0.0=pyhd8ed1ab_0
- prometheus_client=0.16.0=pyhd8ed1ab_0
- prompt-toolkit=3.0.38=pyha770c72_0
- prompt_toolkit=3.0.38=hd8ed1ab_0
- psutil=5.9.4=py311he2be06e_0
- ptyprocess=0.7.0=pyhd3deb0d_0
- pure_eval=0.2.2=pyhd8ed1ab_0
- pycparser=2.21=pyhd8ed1ab_0
- pygments=2.14.0=pyhd8ed1ab_0
- pyopenssl=23.0.0=pyhd8ed1ab_0
- pyrsistent=0.19.3=py311he2be06e_0
- pysocks=1.7.1=pyha2e5f31_6
- python=3.11.0=h3ba56d0_1_cpython
- python-dateutil=2.8.2=pyhd8ed1ab_0
- python-fastjsonschema=2.16.3=pyhd8ed1ab_0
- python-json-logger=2.0.7=pyhd8ed1ab_0
- python_abi=3.11=3_cp311
- pytz=2022.7.1=pyhd8ed1ab_0
- pyyaml=6.0=py311he2be06e_5
- pyzmq=25.0.0=py311h0f351f6_0
- readline=8.1.2=h46ed386_0
- requests=2.28.2=pyhd8ed1ab_0
- rfc3339-validator=0.1.4=pyhd8ed1ab_0
- rfc3986-validator=0.1.1=pyh9f0ad1d_0
- send2trash=1.8.0=pyhd8ed1ab_0
- setuptools=67.4.0=pyhd8ed1ab_0
- six=1.16.0=pyh6c4a22f_0
- sniffio=1.3.0=pyhd8ed1ab_0
- soupsieve=2.3.2.post1=pyhd8ed1ab_0
- stack_data=0.6.2=pyhd8ed1ab_0
- terminado=0.17.1=pyhd1c38e8_0
- tinycss2=1.2.1=pyhd8ed1ab_0
- tk=8.6.12=he1e0b03_0
- tomli=2.0.1=pyhd8ed1ab_0
- tornado=6.2=py311he2be06e_1
- traitlets=5.9.0=pyhd8ed1ab_0
- typing-extensions=4.4.0=hd8ed1ab_0
- typing_extensions=4.4.0=pyha770c72_0
- tzdata=2022g=h191b570_0
- urllib3=1.26.14=pyhd8ed1ab_0
- wcwidth=0.2.6=pyhd8ed1ab_0
- webencodings=0.5.1=py_1
- websocket-client=1.5.1=pyhd8ed1ab_0
- wheel=0.38.4=pyhd8ed1ab_0
- xz=5.2.6=h57fd34a_0
- yaml=0.2.5=h3422bc3_2
- zeromq=4.3.4=hbdafb3b_1
- zipp=3.15.0=pyhd8ed1ab_0
- pip:
- ipywidgets==8.0.4
- jupyterlab-widgets==3.0.5
- widgetsnbextension==4.0.5
prefix: /opt/homebrew/Caskroom/miniconda/base/envs/ipywidgets-test

Command Line Output (nbconvert)
[NbConvertApp] Converting notebook hello.ipynb to html
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[NbConvertApp] Writing 591147 bytes to hello.html
Browser Output
Source map error: Error: request failed with status 404
Resource URL: https://unpkg.com/@jupyter-widgets/html-manager@*/dist/embed-amd.js
Source Map URL: embed-amd-render.js.map

Cookie “” has been rejected as third-party. require.min.js
Cookie “” has been rejected as third-party. latest.js
Cookie “” has been rejected as third-party. MathJax.js
Cookie “” has been rejected as third-party. embed-amd.js
Cookie “” has been rejected as third-party. TeX-AMS_CHTML-full.js
Cookie “” has been rejected as third-party. embed-amd.js
Cookie “” has been rejected as third-party. Safe.js
strict mode: use allowUnionTypes to allow union type keyword at "#/properties/state/additionalProperties/properties/buffers/items/properties/path/items" (strictTypes) embed-amd.js:20:491971
Cookie “” has been rejected as third-party. Safe.js
strict mode: use allowUnionTypes to allow union type keyword at "#/properties/state/additionalProperties/properties/buffers/items/properties/path/items" (strictTypes) embed-amd.js:10:2281999
Source map error: Error: request failed with status 404
Resource URL: https://unpkg.com/@jupyter-widgets/html-manager@*/dist/embed-amd.js
Source Map URL: embed-amd-render.js.map

Cookie “” has been rejected as third-party.

image

If using JupyterLab

  • JupyterLab version: 3.5.0
Installed Labextensions
Selected Jupyter core packages...
IPython          : 8.11.0
ipykernel        : 6.21.2
ipywidgets       : 8.0.4
jupyter_client   : 8.0.3
jupyter_core     : 5.2.0
jupyter_server   : 2.3.0
jupyterlab       : 3.5.0
nbclient         : 0.7.2
nbconvert        : 7.2.9
nbformat         : 5.7.3
notebook         : 6.5.2
qtconsole        : not installed
traitlets        : 5.9.0

JupyterLab v3.5.0
/opt/homebrew/Caskroom/miniconda/base/envs/ipywidgets-test/share/jupyter/labextensions
jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
@jupyter-widgets/jupyterlab-manager v5.0.5 enabled OK (python, jupyterlab_widgets)

Known nbextensions:
config dir: $HOME/.jupyter/nbconfig
notebook section
jupyter-js-widgets/extension enabled
- Validating: OK
config dir: /opt/homebrew/Caskroom/miniconda/base/envs/ipywidgets-test/etc/jupyter/nbconfig
notebook section
jupyter-js-widgets/extension enabled
- Validating: OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant