【问题标题】:Jupyter Lab controls no longer work ipywidgets with ipymplJupyter Lab 控件不再与 ipympl 一起使用 ipywidgets
【发布时间】:2022-06-11 01:49:15
【问题描述】:

我一直使用以下工作流程来全面更新我的 Jupyter Lab 工作环境:

$ rmvirtualenv my_env
$ mkvirtualenv --python=`which python` my_env
[my_env] $ pip install -r requirements.txt
[my_env] $ jupyter lab build
[my_env] $ jupyter lab

然而,最近,在这些步骤之后:

  1. 我的小部件全部失效。我可以操作和与他们互动,但他们控制的数字根本没有改变。
  2. 所有小部件控件都从它们控制的图形上方移动到其下方。

最近未以这种方式更新的虚拟环境中的项目继续正常工作,并且可靠地更新它们会使它们停止工作。

这种情况始终如一(我现在已经破坏了六个确认该模式的项目),甚至对于托管在我本地计算机之外的笔记本(例如this one hosted on Binder)也是如此。当不涉及 ipympl 时,控制小部件本身似乎工作正常(例如,在笔记本 like this one 中)。我还确认观察到的行为独立于浏览器和本地机器(至少 macOS 与 iOS)。

最近是否有关于 Jupyter Lab、ipywidgets 或 ipympl 的更改可能导致此问题?


典型的更新后(非工作)配置:

$ jupyter --version
Selected Jupyter core packages...
IPython          : 8.4.0
ipykernel        : 6.13.1
ipywidgets       : 7.7.0
jupyter_client   : 7.3.4
jupyter_core     : 4.10.0
jupyter_server   : 1.17.1
jupyterlab       : 3.4.3
nbclient         : 0.6.4
nbconvert        : 6.5.0
nbformat         : 5.4.0
notebook         : 6.4.12
qtconsole        : not installed
traitlets        : 5.2.2

$ jupyter labextension list 
JupyterLab v3.4.3
/Users/Rax/Documents/Projects/Coding/Python/venvs/picollisions/share/jupyter/labextensions
        jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
        nbdime-jupyterlab v2.1.1 enabled OK
        jupyter-matplotlib v0.11.1 enabled OK
        @jupyterlab/git v0.37.1 enabled OK (python, jupyterlab-git)
        @jupyter-widgets/jupyterlab-manager v3.1.0 enabled OK (python, jupyterlab_widgets)
        @kiteco/jupyterlab-kite v2.0.2 enabled OK (python, jupyterlab_kite)

Other labextensions (built into JupyterLab)
   app dir: /Users/Rax/Documents/Projects/Coding/Python/venvs/picollisions/share/jupyter/lab

典型的预更新(工作)配置:

$ jupyter --version
jupyter core     : 4.7.1
jupyter-notebook : 6.4.3
qtconsole        : not installed
ipython          : 7.26.0
ipykernel        : 6.2.0
jupyter client   : 6.1.12
jupyter lab      : 3.1.10
nbconvert        : 6.1.0
ipywidgets       : 7.6.4
nbformat         : 5.1.3
traitlets        : 5.0.5

jupyter labextension list
JupyterLab v3.1.10
/Users/Rax/Documents/Projects/Coding/Python/venvs/picollisions/share/jupyter/labextensions
        nbdime-jupyterlab v2.1.0 enabled OK
        jupyter-matplotlib v0.9.0 enabled OK
        @jupyterlab/git v0.32.2 enabled OK (python, jupyterlab-git)
        @jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)
        @kiteco/jupyterlab-kite v2.0.2 enabled OK (python, jupyterlab_kite)

/usr/local/share/jupyter/labextensions
        jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)

Other labextensions (built into JupyterLab)
   app dir: /Users/Rax/Documents/Projects/Coding/Python/venvs/picollisions/share/jupyter/lab

典型要求:

#...
ipywidgets                 
ipympl

jupyterlab >=3.1                
jupyterlab-git                 
jupyterlab-kite >=2.0.2        

(我尝试省略 Kite 以查看是否是罪魁祸首。无论如何,它在 Binder 版本中不存在。)

【问题讨论】:

  • 交叉发布 herehere。如果您交叉发布,请列出您交叉发布的所有地点。否则,您可能会用相同的建议来划分人们的时间。也通过链接,它允许其他人找到解决方案。
  • @Wayne 恐怕这根本不是我的经验(在第一原则上也不正确)。无论如何,这些线程的答案将在这里起作用,因此请随时提供,我会接受。

标签: matplotlib jupyter-lab ipywidgets ipympl


【解决方案1】:

注意here,有一个正在排序的错误。

现在的选项:

1

正如here 所讨论的,如果您将fig.canvas.draw() 添加为plot_logisitic 的最后一行,正如@ianhi here 所建议的那样,您的代码将适用于给您带来问题的包版本。
这种方法还有一个额外的好处,实际上是目前和未来的最佳实践。

2

如果您不想添加旧版本,请使用旧版本。 当前启动from here 导致了这种情况。原始代码(不添加fig.canvas.draw())工作的相关项目的版本是here

【讨论】:

    猜你喜欢
    • 2018-05-29
    • 2019-04-27
    • 1970-01-01
    • 2018-09-07
    • 2021-06-16
    • 2019-11-11
    • 2019-03-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多