manzt / anywidget

reusable widgets made easy
https://anywidget.dev
MIT License
500 stars 39 forks source link

"Exception opening new com" #103

Closed paul-shannon closed 1 year ago

paul-shannon commented 1 year ago

@manzt - thank you for this python package. It looks like it will be so much easier to work with than cookiecutter - which on a fresh install for jupyterlab, fails to run to completion.
Alas, I have a small problem with your CounterWidget demo. I hope you can help. I use the code you provide here - verbatim, as best I can tell. On executing this line

w = CounterWidget()

the javascript console shows: image

Any suggestions? Any more information I can supply?

manzt commented 1 year ago

I'm not able to reproduce the error on a fresh install of anywidget and jupyterlab (python 3.11 on macOS). Have you tried just using ipywidgets? anywidget depends on ipywidgets for opening the comm, so I'm curious if you see the same error without anywidget, e.g.,

import ipywidgets

ipywidgets.IntSlider(value=10)

would you be able to try that out?

Otherwise, could you include a pip freeze as well as what version of Python you are using?

paul-shannon commented 1 year ago

Thanks for the speedy response. I'm grateful.

As you suspected, ipywidgets (8.0.6) produces the same error:

import ipywidgets
ipywidgets.IntSlider(value=10)

image

Here are some of what might be the most relevant pip freeze results, with the full list then attached in a file.


(py3105)> pip freeze | grep ipywidget
ipywidgets==8.0.6
anywidget==0.2.0

jupyter-events==0.6.3
jupyter-ui-poll==0.2.2
jupyter-ydoc==0.2.3
jupyter_client==8.1.0
jupyter_core==5.3.0
jupyter_server==2.5.0
jupyter_server_fileid==0.9.0
jupyter_server_terminals==0.4.4
jupyter_server_ydoc==0.8.0
jupyterlab==3.6.3
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.7
jupyterlab_server==2.22.0

[freeze.txt](https://github.com/manzt/anywidget/files/11213578/freeze.txt)
paul-shannon commented 1 year ago

I bungled the full freeze list file attachment. Here it is in clear text:

aiofiles==22.1.0
aiosqlite==0.18.0
anyio==3.6.2
anywidget==0.2.0
appnope==0.1.3
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
arrow==1.2.3
asttokens==2.2.1
attrs==22.2.0
Babel==2.12.1
backcall==0.2.0
beautifulsoup4==4.12.2
binaryornot==0.4.4
bleach==6.0.0
certifi==2022.12.7
cffi==1.15.1
chardet==5.1.0
charset-normalizer==3.1.0
click==8.1.3
comm==0.1.3
cookiecutter==2.1.1
debugpy==1.6.7
decorator==5.1.1
defusedxml==0.7.1
executing==1.2.0
fastjsonschema==2.16.3
fqdn==1.5.1
idna==3.4
ipykernel==6.22.0
ipython==8.12.0
ipython-genutils==0.2.0
ipywidgets==8.0.6
isoduration==20.11.0
jedi==0.18.2
Jinja2==3.1.2
jinja2-time==0.2.0
jp-proxy-widget==1.0.10
json5==0.9.11
jsonpointer==2.3
jsonschema==4.17.3
jupyter-events==0.6.3
jupyter-ui-poll==0.2.2
jupyter-ydoc==0.2.3
jupyter_client==8.1.0
jupyter_core==5.3.0
jupyter_server==2.5.0
jupyter_server_fileid==0.9.0
jupyter_server_terminals==0.4.4
jupyter_server_ydoc==0.8.0
jupyterlab==3.6.3
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.7
jupyterlab_server==2.22.0
MarkupSafe==2.1.2
matplotlib-inline==0.1.6
mistune==2.0.5
mypy-extensions==1.0.0
nbclassic==0.5.5
nbclient==0.7.3
nbconvert==7.3.1
nbformat==5.8.0
nest-asyncio==1.5.6
notebook==6.5.4
notebook_shim==0.2.2
numpy==1.24.2
packaging==23.0
pandocfilters==1.5.0
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
platformdirs==3.2.0
prometheus-client==0.16.0
prompt-toolkit==3.0.38
psutil==5.9.4
psygnal==0.9.0
ptyprocess==0.7.0
pure-eval==0.2.2
pycparser==2.21
Pygments==2.15.0
pyrsistent==0.19.3
python-dateutil==2.8.2
python-json-logger==2.0.7
python-slugify==8.0.1
PyYAML==6.0
pyzmq==25.0.2
requests==2.28.2
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
Send2Trash==1.8.0
six==1.16.0
sniffio==1.3.0
soupsieve==2.4
stack-data==0.6.2
terminado==0.17.1
text-unidecode==1.3
tinycss2==1.2.1
tomli==2.0.1
tornado==6.2
traitlets==5.9.0
typing_extensions==4.5.0
uri-template==1.2.0
urllib3==1.26.15
watchfiles==0.19.0
wcwidth==0.2.6
webcolors==1.13
webencodings==0.5.1
websocket-client==1.5.1
widgetsnbextension==4.0.7
y-py==0.5.9
ypy-websocket==0.8.2
manzt commented 1 year ago

I should be able to take a closer look later today or tomorrow, but it seems like an issue with ipywidgets/jupyter and I'm not sure how much I'll be able to help. Can you also share python version and operating-system?

paul-shannon commented 1 year ago

Thanks, Trevor.
Python 3.10.6 macOS Ventura 13.3.1 Chrome Version 112.0.5615.49 (Official Build) (x86_64)

manzt commented 1 year ago

Haven't been able to get to the bottom of this, but @keller-mark pointed me to this issue previously in vitessce-python, which seems similar:

"I believe the issue was more generally with installing an ipywidget within the same notebook and then trying to render it. Refreshing the browser tab containing the notebook after running !pip install seems to resolve it but is not an ideal solution."

^ Hopefully the above suggestion works for you

paul-shannon commented 1 year ago

Hi Trevor, Thanks for chasing that down. I last dallied in the jupyterlab world 5 years ago, too early I concluded at the time. This bug and workaround suggest it may still be too early. For my purposes, anyway. I am grateful for your help.