Jupyter更换主题和扩展包

最近一次修订时间为 2020-11-12



1 Jupyter Notebook的主题

  默认主题如下
这里写图片描述

  虽然很方便,但是看长时间眼睛会很疼。
  查了下资料,github大神很多
  https://github.com/dunovank/jupyter-themes

1.1 主题

  oceans16 syntax

这里写图片描述

  chesterish syntax

这里写图片描述

1.2 Requirements

  • Python 2.7, 3.4, 3.5, 3.6
  • Jupyter (Anaconda recommended)
  • matplotlib

  jupyter notebook的安装可以参考这篇博客:本地远程访问Ubuntu16.04.3服务器上的Jupyter notebook

1.3 Install with pip

# install jupyterthemes
pip install jupyterthemes==0.19.1

# upgrade to latest version
pip install --upgrade jupyterthemes

我安装的主题版本为 0.19.1,不建议,upgrade
时代在发展,科技在进步……upgrade后,你会发现,cell 的output 总会少了一部分,扎心,一年前时代不是这样子的……
我们也得与时俱进拉,解决办法如下 Jupyter notebook 输出部分显示不全的问题

vim /root/.jupyter/custom/custom.css

div.output_area 新增一句 padding: 13px;

div.output_area {
display: -webkit-box;
padding: 13px;
}

  具体主题DIY可以参考前面的github,比如

jt -t onedork -f fira -fs 13


比如

jt -t chesterish -T

这里写图片描述

安装完成后会发现 /your_home/.jupyter 目录下多了一个 custom 文件夹

1.4 错误小节

如果安装 jupyterthemes 报错(jupyter版本过低)

notebook 5.7.0 has requirement jupyter-core>=4.4.0, but you'll have jupyter-core 4.3.0 which is incompatible.

先升级下notebook,Upgrade to Jupyter (v. 4.4.0) notebook (v. 5.3.1) makes kernels inaccessible to notebook

conda upgrade notebook

这时候 jupyter notebook --allow-root 可能会出现如下错误

libsodium.so.23: cannot open shared object file: No such file or directory

解决方法
Error after upgrading to 1.0.8: libsodium.so.23: cannot open shared object file: No such file or directory

conda install -c conda-forge libsodium


2 Jupyter Notebook的扩展功能

  标准的 Jupyter Notebook 很不错,但还有更多的扩展,其中集成了大量的函数。

# Install Jupyterextension package
pip install jupyter_contrib_nbextensions==0.5.0
jupyter contrib nbextension install --user

# Install configurator
pip install jupyter_nbextensions_configurator==0.4.0

安装完成后会发现 /your_home/.jupyter 目录下多了一个 nbconfig 文件夹

在安装了 Configurator 之后,你可以看到一个新的 「Nbextensions」 标签。(github 地址如下jupyter_contrib_nbextensions),我的 pip 版本 为 pip 9.0.1. 最好别用最新的 pip 安装,可能出现各种问题!

这里写图片描述

  我添加了Collapsible Headings的功能

   Collapsible Headings可以将 notebook 里的长代码折叠,而不用再辛苦地滚动浏览。根据我的经验,当进行探索性数据分析和画图表的时候,我需要写很长的代码,经常需要滚动查询很久才能找到我想查看的代码。现在你可以自由选择将代码折叠或展开。并且我认为你甚至可以做一个目录(我尚未尝试这种扩展)

这里写图片描述

还有比如代码补全功能
在这里插入图片描述

更多拓展功能和小技巧请参考

比如:

在这里插入图片描述
在这里插入图片描述

  • 2
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值