1. 主题设置
Jupyter默认白色的背景用久了有点刺眼,就想着换个背景,记录一下。
首先,打开Anaconda Prompt,安装相应模块。
pip install jupyterthemes
如果速度比较慢记得更换不同的镜像。
安装完成后,可以用如下命令看具体有哪些主题:
jt -l
如果要设置某个主题,可以用如下命令:
jt -t oceans16
主题还原命令如下:
jt -r
最后附上我自己用的一个主题和具体的设置。
jt -t onedork -f fira -fs 13 -cellw 90% -ofs 11 -dfs 11 -T -N
2. 代码自动补全
pip install jupyter_contrib_nbextensions
然后重启Jupyter,如下图所示勾选Hinterland
3. 代码自动换行
- 首先通过以下命令找到配置文件
jupyter --config-dir
- 进入 C:\Users\xxx.jupyter\nbconfig 路径下,找到notebook.json这个文件,如果没有,自行添加即可
- 在其中写入以下代码
{
"load_extensions": {
"nbextensions_configurator/config_menu/main": true,
"contrib_nbextensions_help_item/main": true,
"hinterland/hinterland": true,
"jupyter-js-widgets/extension": true,
"codefolding/main": false,
"code_font_size/code_font_size": false,
"toc2/main": true,
"scratchpad/main": false,
"code_prettify/code_prettify": false,
"autoscroll/main": false,
"python-markdown/main": false,
"scroll_down/main": false,
"snippets/main": false,
"ruler/main": false,
"notify/notify": false,
"hide_input/main": false,
"freeze/main": false,
"hide_input_all/main": false,
"qtconsole/qtconsole": false,
"code_prettify/autopep8": false
},
"MarkdownCell": {
"cm_config": {
"lineWrapping": true
}
},
"CodeCell": {
"cm_config": {
"lineWrapping": true
}
},
"Cell": {
"cm_config": {
"lineNumbers": true
}
},
"Notebook": {
"Header": true,
"Toolbar": true
},
"toc2": {
"number_sections": false,
"skip_h1_title": true,
"collapse_to_match_collapsible_headings": false
}
}
注意:在我自己实验的过程中,发现如果"codefolding/main"设置为了true,再更换主题,开启代码行号的时候行号离代码就会很近,看着有点不舒服,效果如下: