我使用的是带有轻量级主题的JupyterLab,当我将笔记本导出为HTML时,我看到了以下内容:

我期待看到的是这样的情况:

对环境有什么想法吗?
发布于 2020-06-18 16:12:11
我也有过同样的问题。经过几个小时的调试,我意识到它必须使用jupyter-theme库(至少对我来说是这样)。我安装了一个暗主题,我认为nbconverter使用的是您的jupyter也使用的任何设置,因此黑暗设置影响了html转换。
解决方案只是用:$ jt -r恢复默认值
如果不起作用,请参考以下线程:https://github.com/dunovank/jupyter-themes/issues/86
发布于 2021-04-30 13:56:34
从命令行运行:
jupyter nbconvert --execute --to html /path/to/example.ipynb --HTMLExporter.theme=dark
添加--execute可以保证在保存之前呈现情节。
你也可以用黑色的主题来制作黑色的情节。
import plotly.io as pio
pio.templates.default = "plotly_dark"

发布于 2020-05-25 15:16:11
我也遇到了同样的问题。不仅呈现的html有一个黑暗的背景,这使得x和y轴标签和刻度不可读(它们在颜色上是黑色的),而且在块之间也有奇怪的对齐。
虽然我不知道如何通过编程纠正它,但我确实在周围找到了一份工作。
Try Jupyter LabLorentz.ipynb (或任何.ipynb文件)。您会发现这个Lorentz.html被正确地呈现。Lorentz.html的主体和标题替换为不正确呈现的html文件old_foo.html的正文(本质上,我们使用Lorentz.html的样式来表示old_foo.html的正文)。Lorentz.html重命名为new_foo.html。打开new_foo.html,您会发现它是正确呈现的。如果您运行new_foo.html和old_foo.html之间的差异,您将看到不同之处在于一大块样式代码。
我不确定这是我端的配置错误还是jupyter实验室的错误。
--
$ jupyter --version
jupyter core : 4.6.3
jupyter-notebook : 6.0.3
qtconsole : not installed
ipython : 7.14.0
ipykernel : 5.3.0
jupyter client : 6.1.3
jupyter lab : 2.1.3
nbconvert : 5.6.1
ipywidgets : not installed
nbformat : 5.0.6
traitlets : 4.3.3从jupyter实验室导出的Vanila HTML:

用jupyter实验室在线操场上的造型代替造型:

更新
此黑客不再适用于以下jupyter版本的jupyter:
╰─$ jupyter --version
jupyter core : 4.6.3
jupyter-notebook : 6.1.4
qtconsole : not installed
ipython : 7.18.1
ipykernel : 5.3.4
jupyter client : 6.1.7
jupyter lab : 2.2.8
nbconvert : 6.0.6
ipywidgets : not installed
nbformat : 5.0.7
traitlets : 5.0.4https://stackoverflow.com/questions/60894682
复制相似问题