Javascript错误:JupyterLab中未定义IPython

2024-10-05 13:25:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我有最新的水蟒包。每次我试图使用Python3.6.6绘制一些东西时,我都会在JupyterLab中得到以下错误。。。

Javascript Error: IPython is not defined

当我使用ipython内核在Spyder中运行相同的代码时,它工作得很好。一直在网上到处找,但似乎不知道发生了什么。 任何帮助都将不胜感激。


Tags: 代码is错误ipython绘制noterrorjavascript
3条回答

Jupyter Lab通过jupyter-matplotlib extension支持交互式matplotlib。安装过程稍微复杂一些,但工作正常。

与之前一样,在打印之前调用iPython magic命令非常重要:

用法:

%matplotlib widget

安装:

使用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

使用pip

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

%matplotlib笔记本在interact中不工作,现在需要使用%matplotlib inline

添加:

    %matplotlib inline

在绘制图表之前。

Quoted from

需要与JupyterLab一起使用%matplotlib inline

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

相关问题 更多 >

    热门问题