mpl-extensions / mpl-interactions

Sliders to control matplotlib and other interactive goodies. Works in any interactive backend and even uses ipywidgets when in a Jupyter notebook
https://mpl-interactions.rtfd.io
BSD 3-Clause "New" or "Revised" License
132 stars 20 forks source link

joss review: installation issues #281

Closed ianhi closed 1 year ago

ianhi commented 1 year ago

from @flekschas in https://github.com/openjournals/joss-reviews/issues/5651#issuecomment-1641072224

I followed https://mpl-interactions.readthedocs.io/en/stable/install.html#setup-for-jupyterlab-3 and tried to run the Basic Example from https://mpl-interactions.readthedocs.io/en/stable/index.html#basic-example with JupyterLab v4.0.2 on a M1 MacBook but can't get it to work. image Not sure what I might have done wrong or missing, but unfortunately, I didn't get mpl-interactions to work.

Addressing the installation instructions

These seem like issues with your ipympl installation. The installation [jupyter] addition to the installation instructions just makes a best effort to install compatible versions of ipympl and ipywidgets: https://github.com/mpl-extensions/mpl-interactions/blob/10b1a278a0ba952a830ea9e629a06531c0dc47d3/setup.cfg#L42-L44

Did you already have a version of ipywidgets/ipympl installed in your environment, if so it's possible that that led to installation issues which are an unfortunately common issue for ipympl.

For me the following steps led to a working installation for jupyterlab 4.0.3:

mamba create -n test-jlab4 -c conda-forge jupyterlab=4
mamba activate test-jlab4
pip install mpl-interactions[jupyter]

To troubleshoot the ipympl installation I would recommend first printing out the versions as done in the ipympl issue template: python -c "import sys; print('\n',sys.version); import ipympl; print('ipympl version:', ipympl.__version__)" && jupyter --version && jupyter nbextension list && jupyter labextension list

which gave the following for my working installation

Installed versions ``` 3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 18:08:17) [GCC 12.2.0] ipympl version: 0.9.3 Selected Jupyter core packages... IPython : 8.14.0 ipykernel : 6.24.0 ipywidgets : 8.0.7 jupyter_client : 8.3.0 jupyter_core : 5.3.1 jupyter_server : 2.7.0 jupyterlab : 4.0.3 nbclient : 0.8.0 nbconvert : 7.7.2 nbformat : 5.9.1 notebook : not installed qtconsole : not installed traitlets : 5.9.0 JupyterLab v4.0.3 /home/ian/mambaforge/envs/test-jlab4/share/jupyter/labextensions jupyter-matplotlib v0.11.3 enabled OK jupyterlab_pygments v0.2.2 enabled X (python, jupyterlab_pygments) @jupyter-widgets/jupyterlab-manager v5.0.8 enabled OK (python, jupyterlab_widgets) /home/ian/.local/share/jupyter/labextensions nbdime-jupyterlab v2.1.1 enabled X The following extensions are outdated: jupyterlab_pygments nbdime-jupyterlab Consider checking if an update is available for these packages. ```

Using mpl-interactions outside the notebook

You can also use mpl-interactions directly from a python script. Taking that example and running it without the %matplotlib ipympl magic from a python file then one of the other interactive matplotlib backends (e.g. the qt backend) will be chosen by default by matplotlib and two windows should pop up, allowing use of the library without ipywidgets:

image

Hopefully this will allow testing of the library independent of installation issues with ipympl

flekschas commented 1 year ago

I'll give it another try tonight

flekschas commented 1 year ago

Create a fresh environment from scratch works! 🎉 Thanks for the detailed description/response. Will update my review accordingly

flekschas commented 1 year ago

Feel free to close this issue :)