Closed superstar54 closed 6 months ago
Thanks for opening, I'll try to have a look. I'm curious, are you able to get other (non-anywidget) Jupyter Widgets to work in this environment? For example ipyvega.
I am not able to reproduce:
requirements.txt
jupyterlab==3.4.8
jupyterlab-widgets==1.1.4
notebook==6.4.12
ipywidgets==7.7.4
ipywidgets-extended==1.1.1
jupyterlab-widgets==1.1.4
anywidget==0.9.4
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
jupyter lab
import anywidget
import traitlets
class CounterWidget(anywidget.AnyWidget):
_esm = """
function render({ model, el }) {
let count = () => model.get("value");
let btn = document.createElement("button");
btn.innerHTML = `count is ${count()}`;
btn.addEventListener("click", () => {
model.set("value", count() + 1);
model.save_changes();
});
model.on("change:value", () => {
btn.innerHTML = `count is ${count()}`;
});
el.appendChild(btn);
}
export default { render };
"""
value = traitlets.Int(0).tag(sync=True)
CounterWidget()
If you are able to provide a minimal reproducible example, hopefully we can sort it out.
I'm encountering something similar in jupyterlite at: https://jhsmit.github.io/ipymolstar-demo/lab/index.html
336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1 Error: Module anywidget, version 0.9.7 is not registered, however, 0.9.2 is
at f.loadClass (134.fe2572ece3b7955c89bb.js?v=fe2572ece3b7955c89bb:1:75054)
at f.loadModelClass (336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1:10728)
at f._make_model (336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1:7516)
at f.new_model (336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1:5136)
at f.handle_comm_open (336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1:3893)
at _handleCommOpen (134.fe2572ece3b7955c89bb.js?v=fe2572ece3b7955c89bb:1:73470)
at C._handleCommOpen (default.js:1119:19)
at async C._handleMessage (default.js:1286:30)
when I add %pip install "anywidget==0.9.2"
it fixes the issue
I am encountering an issue with rendering in Jupyter notebook 6.4.12 as well using anywidget = 0.9.7 It works fine in Jupyter Lab 4, Notebook 7, and vs code but not in older notebooks.
For the widget we are building we really need to to work in all of the environments.
Here is the error being shown in the console when calling the widget:
I'm encountering something similar in jupyterlite at
This is related to #385. I'm not sure of a workaround since the version of anywidget installed when building the JupyterLite notebook needs to match that installed in the front end. This dependency management is handled by JupyterLite and not something we can handle directly. Ideally, JupyterLite would load the JS code from a CDN like the HTML version.
I am encountering an issue with rendering in Jupyter notebook 6.4.12 as well using anywidget = 0.9.7
Thanks for chiming in. Please provide a minimal reproducible environment and example. I am not able to reproduce with your current specification. I'd recommend creating a new Python environment.
@manzt I can send my project zipped up if that helps. I attempted with a fresh environment and installed only what was necessary but still see the same issue with the widget showing in labs + vscode but not for notebook.
arcgismapping-anywidgets - Copy.zip
I put only the necessary code in the widget so you can run the example notebook and see what is happening hopefully. Thank you
Hi all, thanks for your patience. I think this should be fixed for v6 notebooks in anywidget 0.9.10. Please give a try and feel free to reopen!
@manzt Great it works! Thank you for fixing that :)
Thanks! @manzt , the new version works!
I have a docker container which has the following packages:
Then my weas-widget package does not work if
anywidget >=0.9.3
. I also tried theCounterWidget
example from anywidget, it does not work too.Here are the error messages from console: