Python is one of the easiest languages to start programming if you’re a beginner. Not only is it extremely easy, but there are also hundreds if not thousands of external libraries that programmers can download and use to further integrate added functionality.
In this article, we’re talking about the “Error displaying widget: model not found” problem when using Jupyter Labs in Python.
Check your ipywidgets version
ipywidgets version 7.5 has a bug that’s known to break Jupyter Labs’ functionality and sometimes affects other libarires as well. If you’re using version 7.5 or above and are facing this problem, try downgrading to version 7 to see if that solves your problem.
Also read: Python vs R: Which one is better?
If downgrading the version didn’t help you, delete ipywidgets and install it again along with ipympl to see if that fixes the problem. Run the following commands one after another in a terminal window.
pip install ipywidgets
conda install -c conda-forge ipympl
Once the installation is complete, check if the lab extensions list is okay by using the following command.
!jupyter labextension list
If the output shows all OK, restart Jupyter Notebook and you’re good to go.
jupyterlab_widgets is a library that helps Jupyter show widgets as program outputs. If for some reason the library ins’t working as expected, you can run into problems. Reinstall the library by entering the following commands one at a time.
pip uninstall jupyterlab_widgets
pip install jupyterlab_widgets
The regular version of matplotlib sometimes causes problems when used with Jupyter. To resolve this, use jupyter-matplotlib instead. You can install the extension straight from the jupyter-matplotlib directory using the command below.
jupyter labextension install js
Reinstall the Jupyter library
Reinstalling Jupyter and all the dependencies can resolve seemingly random issues that may be happening because of missing references or files. To make it easier, we’ve combined the entire process into one command.
jupyter labextension uninstall jupyter-matplotlib && jupyter labextension uninstall @jupyter-widgets/jupyterlab-manager && conda update -y widgetsnbextension && conda update -y nodejs && pip uninstall -y ipympl && pip install git+https://github.com/matplotlib/jupyter-matplotlib.git#egg=ipympl && conda update jupyterlab -y && jupyter labextension install @jupyter-widgets/jupyterlab-manager && jupyter labextension install jupyter-matplotlib && jupyter labextension update --all && jupyter lab build && jupyter nbextension list && jupyter labextension list
Also read: Lost Ark error code 30005: 7 Fixes