Javascript Error: IPython is not defined in JupyterLab

*爱你&永不变心* 提交于 2019-11-29 02:13:28

问题


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.


回答1:


"%matplotlib notebook doesn't work in nteract, you'll need to use %matplotlib inline for now."

Add:

    %matplotlib inline

Before plot the graph.

Quoted from




回答2:


Jupyter Lab does support interactive matplotlib through the jupyter-matplotlib extension. The installation procedure is slightly more involved, but works fine.

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 the Notebook
conda install -c conda-forge widgetsnbextension
# If using JupyterLab
conda install nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib

Using pip

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



回答3:


Need to use %matplotlib inline with JupyterLab

%matplotlib inline 
import matplotlib.pyplot as plt
plt.plot([1,2,3])


来源:https://stackoverflow.com/questions/51922480/javascript-error-ipython-is-not-defined-in-jupyterlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!