Open posita opened 2 years ago
Yeah, it looks like the pyodide-distributed wasm_backend
assumes it's running in a main thread pyodide, which is not the case on pyolite, where everything is running in a webworker: if it wasn't it might wedge the whole application in this case, and you might not see anything (or it would only be in the kernel).
It looks like this choice was added semi-recently: https://github.com/pyodide/pyodide/pull/3061
We'll have to revisit the patches to ensure that they force a backend that we expect.
Thanks @bollwyvl! Please let me know if you discover that this should be filed against pyodide
instead, and I'll be happy to move it over.
I believe this belongs here, and is something we can fix in our patch: we had been relying on setting the MPLBACKEND
environment variable, but it appears that gets overloaded by something explicitly happening in pyodide now.
After finding the issue and updating the patch, as part of declaring it "fixed", we need to get a minimum reproducer for custom rcParams, which are pretty common, into the matplotlib example notebook, as we run through each of those before doing a pyodide release.
Description
Calling
matplotlib.rcParams.update(matplotlib.rcParamsDefault)
before anymatplotlib.pyplot
call will brick the running kernel. More specifically, any call to anymatplotlib.pyplot
function will raiseImportError: cannot import name 'document' from 'js' (unknown location)
thereafter.Reproduce
Create a new notebook (e.g., in https://jupyterlite.rtfd.io/en/latest/try/lab, but I've been able to reproduce this in several installations going back to 0.1.0b11) and paste the following in the first cell:
Select
Run
:arrow_right:Restart Kernel and Run All Cells...
(or click the :fast_forward: icon in the tool bar). You'll get a stack trace like the following:Note: This does not happen in Jupyter Lab (at least not using the recent
jupyter/scipy-notebook
docker image).If you un-comment line 2 or comment line 3 of the original example, your session will be fine.