Javascript Error:IPython未在JupyterLab中定义用法:安装:

2022-08-30 04:41:58

我有最新/更新的Anaconda软件包。每次我尝试使用python 3.6.6绘制一些东西时,我都会在JupyterLab中收到以下错误...

Javascript 错误:未定义 IPython

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


答案 1

Jupyter Lab确实通过jupyter-matplotlib扩展支持交互式matplotlib。安装过程稍微复杂一些,但工作正常。由于ipympl Jupyter Lab版本需要NodeJS,而NodeJS需要Windows 8.1,因此ipympl也有这个要求。

和以前一样,在绘图之前调用iPython魔术命令很重要:

用法:

%matplotlib widget

安装:

注意:如果将此扩展与Jupyter Lab一起使用,建议使用版本> = 3。有关安装旧扩展的更详细的说明,请参阅 ipympl github 上的说明

使用康达

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

使用点数

pip install ipympl

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

答案 2

Jupyter Lab确实通过jupyter-matplotlib扩展支持交互式matplotlib。看看TomNorway的答案

或者,您可以配置 matplotlib 以改用。 没有 那么强大,但它可以拯救你。inlineinlineinteractive

要使用 ,请在绘制图形之前添加此行:inline

    %matplotlib inline

更多信息