Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Error: IPython is not defined in JupyterLab

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.

like image 221
AntMan Avatar asked Aug 19 '18 22:08

AntMan


People also ask

Does JupyterLab use IPython?

The IPython kernel is maintained by the Jupyter team, as a result of the evolution of the project. However, you can also run many other languages, such as Scala, JavaScript, Haskell, Ruby, and more in the Jupyter Notebook Application. Those are community maintained kernels.

What is IPython in jupyter?

The IPython Notebook is now known as the Jupyter Notebook. It is an interactive computational environment, in which you can combine code execution, rich text, mathematics, plots and rich media. For more details on the Jupyter Notebook, please see the Jupyter website.

Why is JupyterLab not working?

Jupyter doesn't load or doesn't work in the browserTry disabling any browser extensions and/or any Jupyter extensions you have installed. Some internet security software can interfere with Jupyter. If you have security software, try turning it off temporarily, and look in the settings for a more long-term solution.


2 Answers

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:

Note: If using this extension with Jupyter Lab, it's recommended to use a version >= 3. For more detailed instructions on installing an old extension than below, see the instructions on ipympl github.

Using conda

conda install -c conda-forge ipympl  # If using JupyterLab 2 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 2 pip install nodejs jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter labextension install jupyter-matplotlib 
like image 171
TomNorway Avatar answered Sep 19 '22 17:09

TomNorway


Jupyter Lab does support interactive matplotlib through the jupyter-matplotlib extension. See TomNorway's answer.

Alternatively, you can configure matplotlib to use inline instead. inline is not as powerful as interactive, but it can save you.

To use inline, add this line before plot the graph:

    %matplotlib inline 

More Info

like image 34
palhares Avatar answered Sep 20 '22 17:09

palhares