我喜欢黑暗题材。但是,Jupyter笔记本的默认主题是浅色,我找不到更改主题/背景色的选项。这是怎么做到的?


当前回答

如果有人有兴趣在启用主题的docker中运行anaconda

docker run -t --rm -p 8888:8888 -v $(pwd):/opt/notebooks continuumio/anaconda3 /bin/bash -c "pip install jupyterthemes; jt -t onedork; /opt/conda/bin/jupyter notebook --ip=0.0.0.0 --port=8888 --notebook-dir=/opt/notebooks --allow-root --no-browser;"

其他回答

conda install jupyterthemes

在Windows系统中不适合我。我用的是水蟒。

但是,

pip install jupyterthemes

在Anaconda Prompt工作过。

使用Kyle Dunovan的jupyter-themes包很容易做到这一点。您可以使用conda安装它。否则,您将需要使用pip。

使用conda安装:

conda install -c conda-forge jupyterthemes

或小毛病:

pip install jupyterthemes

你可以通过以下方法获得可用主题的列表:

jt -l

所以改变你的主题:

jt -t theme-name

要加载主题,最后,重新加载页面。文档和源代码都在这里。在设置主题时,还可以在同一个命令中指定-T(——toolbar)来保留工具栏,否则工具栏将不会显示。如需帮助,请输入jt -h。

简单,Jupyter字体大小和内外背景颜色的全局更改(此更改将影响所有笔记本电脑)。

在Windows下,通过运行命令找到config目录: jupyter——config-dir

在Linux中是~/.jupyter

在此目录中创建子文件夹custom 创建文件custom.css并粘贴:

/* Change outer background and make the notebook take all available width */
.container {
    width: 99% !important;
    background: #DDC !important;
}   

/* Change inner background (CODE) */
div.input_area {
    background: #F4F4E2 !important;
    font-size: 16px !important;
}

/* Change global font size (CODE) */
.CodeMirror {
    font-size: 16px !important;
}  

/* Prevent the edit cell highlight box from getting clipped;
 * important so that it also works when cell is in edit mode */
div.cell.selected {
    border-left-width: 1px !important;
} 

最后,重启Jupyter。结果:

在我改变主题后,它表现得很奇怪。字体很小,看不到工具栏,我真的不喜欢这个新外观。

对于想要还原原有主题的用户,可以按照以下步骤进行操作:

jt -r

您需要在第一次这样做时重新启动Jupyter,之后刷新就足以启用新主题。

或者直接从笔记本里

!jt -r
!pip install jupyterthemes

运行这个库:

from jupyterthemes import get_themes
import jupyterthemes as jt
from jupyterthemes.stylefx import set_nb_theme

这:

set_nb_theme('monokai')

主题:

’monokai’, ’chesterish’, ’oceans16’, ’solarizedl’, ’solarizedd’, ’grade3’, ’onedork’