matplotlib / ipympl

Matplotlib Jupyter Integration
https://matplotlib.org/ipympl/
BSD 3-Clause "New" or "Revised" License
1.59k stars 225 forks source link

Docs request (feature request?): Using ipympl when Jupyter and kernel are in different environments #486

Open gwerbin opened 2 years ago

gwerbin commented 2 years ago

Describe the issue

This issue is a continuation from https://github.com/matplotlib/ipympl/issues/112.

A very common use case involves a centrally-installed Jupyter instance running Jupyter kernels in various task-specific environments.

Examples include a shared Jupyterlab instance installed by a server administrator, or a single user with a highly-customized personal Jupyter configuration.

In these situations, it's usually undesirable (and sometimes impossible) for users to install and run Jupyter within their task-specific environment in order to make use of ipympl as per the official recommendation to use pip install ipympl for both the server/kernel-side package and the client/frontend-side extension.

What are the correct instructions for installing the "frontend" and "backend" components of ipympl separately, so that they can be used in two different environments?

If this is not currently a supported use case, consider this issue a much-desired feature request!

martinRenou commented 2 years ago

Thanks for opening an issue!

It's currently not really possible to split them properly as far as I know, you'd have to install somewhat matching ipympl versions in both environments.

Ideally we should have a separate package for the backend (ipympl) and for the frontend (jupyter-matplotlib).

gwerbin commented 2 years ago

It's currently not really possible to split them properly as far as I know, you'd have to install somewhat matching ipympl versions in both environments.

Given that the kernel-side environment is usually controlled fully by individual users, this doesn't seem like an unreasonable restriction and is certainly better than nothing in the short term. Is it good enough to check jupyter labextension list and try to install the same version that is shown there, or does the jupyter-matplotlib package use a different versioning numbering system?

It's definitely a bit annoying to have the entire Jupyter frontend pulled into your environment that is only meant to run a kernel server, but still that's better than not being able to do this at all.

martinRenou commented 2 years ago

Is it good enough to check jupyter labextension list and try to install the same version that is shown there, or does the jupyter-matplotlib package use a different versioning numbering system?

ipympl is a bit loose on the jupyter-matplotlib version requirement: https://github.com/matplotlib/ipympl/blob/main/ipympl/_version.py#L3

It's definitely a bit annoying to have the entire Jupyter frontend pulled into your environment that is only meant to run a kernel server

I can understand that, though to be fair, ipympl only installs a bunch of JavaScript files under PREFIX/share/jupyter/labextensions/jupyter-matplotlib/ (totaling less than 2MB probably) that won't be used. And ipympl does not pull the entire jupyterlab.

But I agree we could make things better by splitting both properly. It's something that I'd like to do at some point if I find time.

gyger commented 1 month ago

I was wondering if that could be picked up again. It seems installing extensions directly is deprecated and so it would be wonderful to be able to just install jupyter-matplotlib with conda or pip. At the moment, I would need to install numpy and matplotlib and everything that comes with this in the directory that runs the jupyterlab server.

martinRenou commented 1 month ago

This has been done in ipyleaflet: https://github.com/jupyter-widgets/ipyleaflet/tree/master/python

There has been a split between the Python package ipyleaflet and the JupyterLab extension jupyter-leaflet, they can now be installed separately (although ipyleaflet depends on jupyter-leafet for convenience and backward compatibility).

We should do it in ipympl too. Though I can't really put any cycles on it myself.