Javascript Error: IPython is not defined in JupyterLab
Javascript Error: IPython is not defined in JupyterLab
我有 latest/updated Anaconda 软件包。每次我尝试使用 python 3.6.6 绘制一些东西时,我都会在 JupyterLab 中收到以下错误...
Javascript Error: IPython is not defined
当我在 Spyder 中使用 ipython 内核 运行 相同的代码时,它工作得很好。一直在网上四处寻找,但似乎无法弄清楚发生了什么。
任何帮助,将不胜感激。
Jupyter Lab 通过 jupyter-matplotlib extension. See 支持交互式 matplotlib。
或者,您可以将 matplotlib 配置为使用 inline
。 inline
虽然没有interactive
强大,但是可以救你
要使用 inline
,请在绘制图形之前添加此行:
%matplotlib inline
Jupyter Lab 通过 jupyter-matplotlib extension 支持交互式 matplotlib。安装过程稍微复杂一些,但工作正常。由于ipympl Jupyter Lab版本需要NodeJS,而NodeJS需要Windows8.1,所以ipympl也有这个要求
和以前一样,在绘图之前调用 iPython 魔术命令很重要:
用法:
%matplotlib widget
安装:
注意:如果将此扩展与 Jupyter Lab 一起使用,建议使用 >= 3 的版本。有关安装旧扩展的更多详细说明,请参阅 instructions on ipympl github。
使用 conda
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
pip install ipympl
# If using JupyterLab 2
pip install nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib
Jupyterlab 支持 jpympl。
你必须把%matplotlib widget
放在jupyterlab的最开头。
您可以在特定单元格中更改为 %matplotlib inline
,并在需要时再次激活 %matplotlib widget
。
否则无论重装多少次,还是会报错
当我尝试在我的 jupyter notebook 中显示 html 格式的内容时,我得到 Ipython not defined in jupyter notebook,我只是导入了该函数并且它起作用了
from IPython.core.display import display, HTML # my imports
annot = coco_dataset.display_image(21, use_url=False) #my function return a html page
HTML(annot) # used for displaying the page
我可以通过安装 ipympl
:
来解决同样的问题
pip install ipympl
然后在剧情前加上%matplotlib ipympl
使用 backtrader 时遇到类似问题。
这为我修复了它:
cerebro.plot(iplot = False)
我有 latest/updated Anaconda 软件包。每次我尝试使用 python 3.6.6 绘制一些东西时,我都会在 JupyterLab 中收到以下错误...
Javascript Error: IPython is not defined
当我在 Spyder 中使用 ipython 内核 运行 相同的代码时,它工作得很好。一直在网上四处寻找,但似乎无法弄清楚发生了什么。 任何帮助,将不胜感激。
Jupyter Lab 通过 jupyter-matplotlib extension. See
或者,您可以将 matplotlib 配置为使用 inline
。 inline
虽然没有interactive
强大,但是可以救你
要使用 inline
,请在绘制图形之前添加此行:
%matplotlib inline
Jupyter Lab 通过 jupyter-matplotlib extension 支持交互式 matplotlib。安装过程稍微复杂一些,但工作正常。由于ipympl Jupyter Lab版本需要NodeJS,而NodeJS需要Windows8.1,所以ipympl也有这个要求
和以前一样,在绘图之前调用 iPython 魔术命令很重要:
用法:
%matplotlib widget
安装:
注意:如果将此扩展与 Jupyter Lab 一起使用,建议使用 >= 3 的版本。有关安装旧扩展的更多详细说明,请参阅 instructions on ipympl github。
使用 conda
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
pip install ipympl
# If using JupyterLab 2
pip install nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib
Jupyterlab 支持 jpympl。
你必须把
%matplotlib widget
放在jupyterlab的最开头。
您可以在特定单元格中更改为 %matplotlib inline
,并在需要时再次激活 %matplotlib widget
。
否则无论重装多少次,还是会报错
当我尝试在我的 jupyter notebook 中显示 html 格式的内容时,我得到 Ipython not defined in jupyter notebook,我只是导入了该函数并且它起作用了
from IPython.core.display import display, HTML # my imports
annot = coco_dataset.display_image(21, use_url=False) #my function return a html page
HTML(annot) # used for displaying the page
我可以通过安装 ipympl
:
pip install ipympl
然后在剧情前加上%matplotlib ipympl
使用 backtrader 时遇到类似问题。 这为我修复了它:
cerebro.plot(iplot = False)