Jupyter相关设置

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. 代码自动换行

  1. 首先通过以下命令找到配置文件
jupyter --config-dir
  1. 进入 C:\Users\xxx.jupyter\nbconfig 路径下,找到notebook.json这个文件,如果没有,自行添加即可
  2. 在其中写入以下代码
{
  "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,再更换主题,开启代码行号的时候行号离代码就会很近,看着有点不舒服,效果如下:
在这里插入图片描述

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值