Jupyter更换主题和扩展包

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bryant_meng/article/details/78609948


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

# upgrade to latest version
pip install --upgrade jupyterthemes

时代在发展,科技在进步……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

这里写图片描述

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
jupyter contrib nbextension install --user

# Install configurator
pip install jupyter_nbextensions_configurator

  在安装了 Configurator 之后,你可以看到一个新的 「Nbextensions」 标签。(时代又进步了,目前测试了下,装不上了……痛失目录展开收放功能……心痛2018,可以去github上看看进展 jupyter_contrib_nbextensions

这里写图片描述

  我添加了Collapsible Headings的功能

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

这里写图片描述

  更多拓展功能和小技巧请参考
  数据科学家效率提升必备技巧之Jupyter Notebook篇

猜你喜欢

转载自blog.csdn.net/bryant_meng/article/details/78609948