Javascript错误:JupyterLab中未定义IPython

Ant*_*Man 33 javascript ipython jupyter-lab

我有最新/更新的Anaconda包.每次我尝试使用python 3.6.6绘制内容时,我在JupyterLab中收到以下错误...

Javascript错误:未定义IPython

当我使用ipython内核在Spyder中运行相同的代码时,它运行正常.一直在网上看,但似乎无法弄清楚发生了什么.任何帮助,将不胜感激.

Tom*_*way 24

Jupyter Lab确实通过jupyter-matplotlib扩展支持交互式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
Run Code Online (Sandbox Code Playgroud)

使用点

pip install ipympl
# If using JupyterLab
conda install nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib
Run Code Online (Sandbox Code Playgroud)

  • 还可以使用“jupyter nbextension enable --py widgetsnbextension”启用该扩展。并重新启动整个笔记本/实验室 (3认同)
  • 在我的机器上,它打印“显示小部件时出错”并且不显示图表。`jupyter labextension list` 命令打印:`@jupyter-widgets/jupyterlab-manager v0.38.1 启用 OK jupyter-matplotlib v0.3.0 启用 OK` (2认同)

pal*_*res 22

"%matplotlib笔记本在nteract中不起作用,你现在需要使用%matplotlib inline."

引自

  • 请注意,引号和链接来自其他项目:`nteract`,而不是Jupyter Lab。这是一种解决方法。似乎[jupyter-matplotlib扩展名](https://github.com/matplotlib/jupyter-matplotlib)是前进的道路,如在单独的答案中所述,我认为应该成为公认的答案,但是谢谢-是确实是一种快速,有用的修复方法! (3认同)
  • 这在 jupyter、jupyter lab 和现在的 jupyter hub 中对我不起作用 (2认同)

Kei*_*van 7

我可以通过安装解决同样的问题ipympl

pip install ipympl
Run Code Online (Sandbox Code Playgroud)

然后%matplotlib ipympl在plot之前添加。


小智 7

使用backtrader时遇到类似的问题。这为我解决了这个问题:

cerebro.plot(iplot = False)
Run Code Online (Sandbox Code Playgroud)


小智 6

  1. Jupyterlab 支持 jpympl。

  2. 您必须输入%matplotlib widgetjupyterlab 的最开头。

您可以更改%matplotlib inline为特定单元格,并%matplotlib widget根据需要再次激活。

否则,无论您重新安装该软件包多少次,您仍然会遇到错误。