Jupyter Notebook 更换主题、设置字体(jupyterthemes的使用)、代码自动补全、变更工作目录(默认目录)

tech2025-08-03  9

本文转载自 https://blog.csdn.net/az9996/article/details/88621028 感谢博主

这次变更jupyter主题借助了jupyterthems库,它来自Github,网址:https://github.com/dunovank/jupyter-themes/blob/master/README.md 感兴趣的可以支持一下原作者!为作者打星!!

操作相当简单,大约划分2~3分钟时间即可配置完成。

注意:每一项修改都需要放置在一起,统一执行生效,若依次输入会导致上一次的修改失效。

=======================================================================

文章目录

一、jupyterthems的使用

1:安装(本文采用的是通过anaconda安装)

命令行选项一览表

2:更换主题(windows 下在CMD中可直接使用)

主题配色简单的截图,方便选择。

3.配置自己的风格

二、代码补全的设置方法

1、使用conda或pip安装jupyter_contrib_nbextensions和jupyter_nbextensions_configurator

三、 修改默认目录

1 生成配置文件

四、快捷键总结


一、jupyterthems的使用

1:安装(本文采用的是通过anaconda安装)

(建议配置下载源为国内站点)

#通过anaconda安装 conda install jupyterthemes #通过pip安装 pip install jupyterthemes

 

命令行选项一览表

(省事儿,用的是机翻,见谅!)

 

2:更换主题(windows 下在CMD中可直接使用)

主题配色简单的截图,方便选择。

#通过命令jt -l 可查看主题列表,效果如下 C:\Users\dell>jt -l Available Themes: chesterish #暗色 grade3 #亮色 gruvboxd #暗色 gruvboxl #淡棕色 monokai #暗色 oceans16 #暗色 onedork #暗色 solarizedd #青色 solarizedl #淡粉色

chesterish

grade3

 gruvboxd

 gruvboxl

monokai

 oceans16

 onedork

solarizedd

 solarizedl

选择主题:

jt -t monokai

还是喜欢原生的主题

jt -r

 

3.配置自己的风格

注意:同时修改多项时,每一项修改都需要放置在一起,统一执行生效,(若依次输入会导致上一次的修改失效,仅保留最后一次修改。)

#选好主题后,设置合适的字体大小.这是我的配置。 jt --lineh 140 -tf ptmono -t onedork -ofs 13 -nfs 14 -tfs 14 -fs 14 -T -N -dfs 10

 效果如下

jt -t oceans16 -f fira -tf ptmono -ofs 10 -nfs 13 -tfs 13 -fs 12 -T -N -lineh 140

最终我用的这个 

jt -t onedork -f fira -tf ptmono -ofs 10 -nfs 13 -tfs 13 -fs 12 -T -N -lineh 140

效果如下:

 

二、代码补全的设置方法

1、使用conda或pip安装jupyter_contrib_nbextensions和jupyter_nbextensions_configurator

conda install jupyter_contrib_nbextensions conda install jupyter_nbextensions_configurator

 安装完成后重新打开jupyternotebook,在菜单栏可以看到 NBextensions这个选项,在其中勾选上“Hinterland”即可打开自动补全。

效果如下:

三、 修改默认目录

1 生成配置文件

打开cmd,输入命令jupyter notebook --generate-config 效果:

Writing default config to: C:\Users\liula\.jupyter\jupyter_notebook_config.py

在提示路径下,找到jupyter_notebook_config.py文件,打开进行编辑

## The directory to use for notebooks and kernels. #c.NotebookApp.notebook_dir = ''

找到jupyter notebook的快捷方式,右键-属性 

删除"%USERPROFILE%/" 重新启动软件,看到图中,新工作目录已经生效.

 更多方法推荐阅读这篇文章 https://www.cnblogs.com/awakenedy/p/9075712.html

四、快捷键总结

Jupyter Notebook快捷键总结 原文链接:https://www.cnblogs.com/peilin1031/p/12326701.html

最新回复(0)