Open surchs opened 3 years ago
@surchs Hi, your detailed report finally helps someone like me two years(and more) later:
nbformat
on the kernel-env according to the error message.
jupyter labextension install jupyterlab-plotly
you provide on the server jupyter-env. It works now:
Currently, the docs for jupyterlab support (e.g. here or here) imply that the user installs both jupyter, plotly, and the jupyterlab-plotly extension in the same python environment.
In jupyter, users can register existing python environments that are then available as additional kernels to run notebooks on. This helps users avoid running jupyter notebooks on the python environment serving the jupyterlab instance or to install jupyter in every python instance they want to run jupyter notebooks in. In my experience, users often have one environment to start the jupyter server in, and then several different kernels for different projects they are working on.
If a user is expecting to install and use plotly in such a setup (1 python environment for jupyter, a separate one to run plotly in) then she needs to install the jupyterlab-plotly extension (and therefore jupyter itself)
in both environments. This is not necessarily intuitive and doesn't fail in a very explicit way if done incorrectly (e.g. here).edit: This is not actually true. Only the environment running the jupyter server needs the jupyterlab-plotly extension. The environment executing inside jupyterlab only needs
nbformat
as an additional dependency. This is correctly raised byValueError: Mime type rendering requires nbformat>=4.2.0 but it is not installed
. So the only case that may be unintuitive is if the user, incorrectly, installs the jupyterlab-plotly extension in the environment used to execute inside jupyter but not in the one serving jupyter. In this case, figures remain blank.Setup
I set up 4 conda environments that either
have or do not have the jupyterlab-plotly extension installed: 2 to run the jupyter server and 2 to install and run plotly inside a jupyter lab instance: edit: the below example is not correct. Only the server environment needs the jupyterlab-plotly extension. The processing environment needsnbformat
, but no extensions.serv-no
Plain jupyter server environment as it might be installed by following the jupyter docs
serv-yes
Same as
serv-no
, but also includes the jupyterlab-plotly extensionproc-no
plain environment with plotly installed, but no jupyterlab-plotly extension. Needs
ipykernel
to register the kernel with the jupyter notebook server. Needs python=3.8 because ipykernel not yet available for 3.9.proc-yes
Same as
proc-no
, but also installedjupyterlab and jupyterlab-plotly extensionedit:nbformat
jupyter labextension install jupyterlab-plotly@4.12.0
edit: this environment only needs
nbformat
to work as expected. The reason the above example works is because installingjupyter
also installsnbformat
. Butjupyter
is not needed in the processing environment. This is correctly explained by raisedValueError
. So instead we can just do:conda install nbformat -y
Reproduce
conda activate serv-no
jupyter lab
proc-yes
edit: this example fails, but only because the server environment is missing the jupyterlab-plotly extension.
Outcome
does not
haveextensionedit:nbformat
has
extensionedit:nbformat
does not
have extensionValueError: Mime type rendering requires nbformat>=4.2.0 but it is not installed
probably not expected toedit: user got the installation backwards): Blank Figure / Doesn't get rendered / no error messagehas
extensioncould reasonably be expected to work):ValueError: Mime type rendering requires nbformat>=4.2.0 but it is not installed
edit: all that is needed to fix is in the error messageI think two possible fixes would be:
1. Add a warning or note to the docs, that the installation instructions assume that jupyter, the extension, and plotly are installed in the same environment and that things can break if notthat the installation of jupyter and the extension needs to also be done in the environment that will run plotlyedit: that the extension must be installed for the server environment for plotly to work correctly.