jupyterlab互动情节

发布于 2021-01-29 19:08:10

我正在使用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

工作正常,但我想要交互式地块。

关注者
0
被浏览
40
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    完成步骤
    1. 安装nodejs,例如conda install nodejs
    2. 安装ipympl,例如pip install ipympl
    3. [可选,但推荐;更新JupyterLab,例如
    pip install --upgrade jupyterlab。


    1. [可选,但推荐;对于本地用户安装,请运行:
    export JUPYTERLAB_DIR="$HOME/.local/share/jupyter/lab"。
    
    1. 安装扩展程序:
    jupyter labextension install @jupyter-widgets/jupyterlab-manager
    jupyter labextension install jupyter-matplotlib
    
    1. 启用小部件:jupyter nbextension enable –py widgetsnbextension。

    2. 重新启动JupyterLab。

    3. 用装饰%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
    


知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看