Jupyter notebook "Run All" 阻止 BokehJS 成功加载

Jupyter notebook "Run All" prevents BokehJS from being successfully loaded

如果我尝试 "Run All" Jupyter notebook 中的单元格,在第一个单元格中使用 output_notebook() 并尝试在下面的单元格中显示图形,我会收到以下错误消息:

/remote/vgrnd5/davidbr/soft/miniconda3/lib/python3.5/site-packages/bokeh/io.py:350: UserWarning:

BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this may be due to a slow or bad network connection. Possible fixes:

  • ALWAYS run output_notebook() in a cell BY ITSELF, AT THE TOP, with no other code
  • re-rerun output_notebook() to attempt to load from CDN again, or
  • use INLINE resources instead, as so:

    from bokeh.resources import INLINE output_notebook(resources=INLINE)

    warnings.warn(_NB_LOAD_WARNING)

虽然 BokehJS 已成功加载(从我在第一个单元格的输出中看到的),但看起来它还没有以某种方式注册,因为如果我 运行 第一个单元格然后 "Run All Bellow",那么它工作正常。 None 错误消息的技巧。

更新:这个问题已经解决,修复将在0.12.2

显然,当使用 "run all" 时,Notebook 的行为是在异步输出发生之前首先对所有单元格执行进行排队。这会导致警告虚假触发。 None 的核心开发人员经常使用 "run all",并且这种特定的排队行为是未知的。您可以关注此问题以获取更新:

https://github.com/bokeh/bokeh/issues/4987

特别是,作为一个直接的解决方法,有这个: