Javascript Error: IPython is not defined in JupyterLab

AntMan picture AntMan · Aug 20, 2018 · Viewed 64.5k times · Source

I have the latest/updated Anaconda package. Everytime I try to plot something using python 3.6.6 I get the following error in JupyterLab...

Javascript Error: IPython is not defined

When I run the same code in Spyder using an ipython kernel, it works just fine. Have been looking all over online but cant seem to figure out what is going on. Any help would be appreciated.

Answer

TomNorway picture TomNorway · Jun 2, 2019

Jupyter Lab does support interactive matplotlib through the jupyter-matplotlib extension. The installation procedure is slightly more involved, but works fine. Since the ipympl Jupyter Lab version requires NodeJS, and NodeJS requires Windows 8.1, ipympl also has this requirement.

As before, it is important to invoke the iPython magic command before plotting:

Usage:

%matplotlib widget

Installation:

Using conda

conda install -c conda-forge ipympl

# If using JupyterLab
conda install nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter lab build

# Later, if updating a previous Lab install:
conda install ipympl
jupyter lab build

Using pip

pip install ipympl
# If using JupyterLab
conda install nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib