Javascript 错误:JupyterLab 中未定义 IPython
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/51922480/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript Error: IPython is not defined in JupyterLab
提问by AntMan
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...
我有最新/更新的 Anaconda 包。每次我尝试使用 python 3.6.6 绘制某些东西时,我都会在 JupyterLab 中收到以下错误...
Javascript Error: IPython is not defined
Javascript 错误:IPython 未定义
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.
当我使用 ipython 内核在 Spyder 中运行相同的代码时,它工作得很好。一直在网上到处找,但似乎无法弄清楚发生了什么。任何帮助,将不胜感激。
采纳答案by palhares
Jupyter Lab does support interactive matplotlib through the jupyter-matplotlibextension. See TomNorway's answer bellow.
Jupyter Lab 确实通过jupyter-matplotlib扩展支持交互式 matplotlib 。请参阅TomNorway的回答如下。
Alternatively, you can configure matplotlib to use inlineinstead. inlineis not as powerful as interactive, but it can save you.
或者,您可以配置 matplotlib 来inline代替使用。inline没有那么强大interactive,但它可以拯救你。
To use inline, add this line before plot the graph:
要使用inline,请在绘制图形之前添加此行:
    %matplotlib inline
回答by TomNorway
Jupyter Lab does support interactive matplotlib through the jupyter-matplotlib extension. The installation procedure is slightly more involved, but works fine.
Jupyter Lab 确实通过jupyter-matplotlib 扩展支持交互式 matplotlib 。安装过程稍微复杂一些,但工作正常。
As before, it is important to invoke the iPython magic command before plotting:
和以前一样,在绘图之前调用 iPython 魔术命令很重要:
Usage:
用法:
%matplotlib widget
%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
回答by AzizSM
Need to use %matplotlib inlinewith JupyterLab
需要%matplotlib inline与 JupyterLab一起使用
%matplotlib inline 
import matplotlib.pyplot as plt
plt.plot([1,2,3])

