jupyterlab互动情节
我正在使用Jupyter笔记本中的Jupyterlab。在我以前使用的笔记本中:
import matplotlib.pyplot as plt
%matplotlib notebook
plt.figure()
x = [1,2,3]
y = [4,5,6]
plt.plot(x,y)
用于交互式地块。现在给我(在jupyterlab中):
JavaScript output is disabled in JupyterLab
我还尝试了魔术(安装了jupyter-matplotlib):
%matplotlib ipympl
但这只是返回:
FigureCanvasNbAgg()
内联图
%matplotlib inline
工作正常,但我想要交互式地块。
-
完成步骤
1. 安装nodejs,例如conda install nodejs
。
2. 安装ipympl,例如pip install ipympl
。
3. [可选,但推荐;更新JupyterLab,例如
pip install --upgrade jupyterlab。
- [可选,但推荐;对于本地用户安装,请运行:
export JUPYTERLAB_DIR="$HOME/.local/share/jupyter/lab"。
- 安装扩展程序:
jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter labextension install jupyter-matplotlib
-
启用小部件:jupyter nbextension enable –py widgetsnbextension。
-
重新启动JupyterLab。
- 用装饰%matplotlib widget。
不推荐使用,但要使小部件扩展在Anaconda中正常运行,可以在终端窗口中运行以下命令:
conda install -y nodejs pip install ipympl pip install --upgrade jupyterlab jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter labextension install jupyter-matplotlib jupyter nbextension enable --py widgetsnbextensio