zoukankan      html  css  js  c++  java
  • 如何修改Jupyter Notebook的主题

    1、windows系统

    (1)下载到本地(使用git bash命令行界面)

    git clone https://github.com/dunovank/jupyter-themes 

    (2)Install with pip

    # install jupyterthemes
    pip install jupyterthemes
    
    # upgrade to latest version
    pip install --upgrade jupyterthemes

    (3)以上安装完成后,可以尝试切换主题了

    # list available themes
    # onedork | grade3 | oceans16 | chesterish | monokai | solarizedl | solarizedd
    jt -l
    Available Themes:
       chesterish
       grade3
       gruvboxd
       gruvboxl
       monokai
       oceans16
       onedork
       solarizedd
       solarizedl
    # select theme...
    jt -t chesterish

    通常jt -t chesterish执行没任何输出说明没问题,但是偶尔也会有报错 
    比如:类似gbk编码方式读文件出错(详细报错信息略)

    解决方法:很简单–报错信息会告诉你哪个py文件出问题了,就在对应的那一行,增加编码格式(UTF-8)即可

    2、linux系统

    (1)linux系统有网
    • 直接下载(前提安装了git命令)
    git clone https://github.com/dunovank/jupyter-themes 
    • 安装方式同上面windows的

      安装过程基本不会出问题,通常都是网络问题,参考下面完全没网的情况

      • 需要注意的是:linux执行jt -l可能报错如下:
    [root@djt_37_152 jupyterthemes-0.18.3]# jt -l
    -bash: jt: command not found
    # 需要配置环境变量
    [root@djt_37_152 jupyterthemes-0.18.3]# vim /etc/profile
    #......在文件最后增加下面一行即可........
    export PATH=$PATH:/usr/local/python27/bin:/root/anaconda2/bin
    # 即加上jt命令所在的bin目录
    
    # source或. 均可使环境变量生效如下
    [root@djt_37_152 jupyterthemes-0.18.3]# . /etc/profile
    [root@djt_37_152 jupyterthemes-0.18.3]# jt -l
    Available Themes: 
       chesterish
       grade3
       gruvboxd
       gruvboxl
       monokai
       oceans16
       onedork
       solarizedd
       solarizedl
    (2)linux系统没网
    • 下载 jupyterthemes-0.18.3.tar.gz(曲线救国)

      windows(或其他可联网的linux机器)下载,压缩后rz上传到linux服务器XXX.XX.XX.XXX

    • 解压后进入目录

    [root@djt_37_152 wj]# tar -zxvf jupyterthemes-0.18.3.tar.gz
    [root@djt_37_152 wj]# cd jupyterthemes-0.18.3
    [root@djt_37_152 jupyterthemes-0.18.3]# pwd
    /search/autotest/wj/packages/jupyterthemes-0.18.3
    [root@djt_37_152 jupyterthemes-0.18.3]# ll
    ؜ԃ 36684
    drwxr-xr-x  9 1000 ops       4096 25 22:45 backports.functools_lru_cache-1.4
    -rw-r--r--  1 root root      6927 25 22:43 backports.functools_lru_cache-1.4.tar.gz
    drwxr-xr-x  4 root root        41 25 17:24 build
    drwxr-xr-x  7 1000 ops       4096 25 22:46 cycler-0.10.0
    -rw-r--r--  1 root root     16553 25 22:45 cycler-0.10.0.tar.gz
    drwxrwxr-x  8 1000 ops       4096 25 22:48 dateutils-0.6.6
    -rw-r--r--  1 root root      3492 25 22:46 dateutils-0.6.6.tar.gz
    drwxr-xr-x  2 root root        43 25 17:24 dist
    drwxr-xr-x  5  501 games       95 4 06:47 jupyterthemes
    drwxr-xr-x  2  501 games      128 4 06:47 jupyterthemes.egg-info
    -rw-r--r--  1  501 games     1091 25 2016 LICENSE.txt
    -rw-r--r--  1  501 games      235 26 2017 MANIFEST.in
    drwxr-xr-x 14 1000 ops       4096 25 17:42 matplotlib-2.1.2
    -rw-r--r--  1 root root  36238363 25 17:28 matplotlib-2.1.2.tar.gz
    -rw-r--r--  1  501 games      911 4 06:47 PKG-INFO
    drwxrwxrwx  8 root root      4096 25 22:42 pyparsing-2.2.0
    -rw-r--r--  1 root root   1232522 25 22:42 pyparsing-2.2.0.tar.gz
    -rw-r--r--  1  501 games     9455 12 09:24 README.md
    -rw-r--r--  1  501 games       62 4 06:43 requirements.txt
    -rw-r--r--  1  501 games      108 4 06:47 setup.cfg
    -rw-r--r--  1  501 games     2884 25 22:35 setup.py
    
    # 很多文件,其中优先看一下requirements.txt
    [root@djt_37_152 jupyterthemes-0.18.3]# cat requirements.txt
    jupyter_core
    ipython>=5.4.1
    matplotlib>=1.4.3
    lesscpy>=0.11.2
    
    #可以看到需要的依赖是这些,不妨直接执行python setup.py install试试
    [root@djt_37_152 jupyterthemes-0.18.3]# python setup.py install
    # (不出意外应该会有很多报错~~~基本都是缺少XXX moduel)
    # 对应下载(曲线救国后rz上传)XXX moduel的xxx.tar.gz文件解压后python setup.py install
    # 如果安装成功会有success,不成功缺什么下什么,进入循环模式。
    # 然后回到jupyterthemes-0.18.3目录尝试继续执行python setup.py install
    # 如果安装成功会有success,不成功缺什么下什么,进入循环模式。
    # 反正直到成功为止。

    万一最后一直不成功(看不到success)呢?比如:我就遇到matplotlib一直install不成功,怎么办? 
    我的方法是(放大招):修改setup.py文件。比如,修改如下

    [root@djt_37_152 jupyterthemes-0.18.3]# vim setup.py
    #把之前install不成功的都注释掉。
    #install_requires = ['jupyter_core', 'ipython>=5.4.1', 'matplotlib>=1.4.3', 'lesscpy>=0.11.2']
    install_requires = ['jupyter_core', 'lesscpy>=0.11.2']
    # 然后回到jupyterthemes-0.18.3目录尝试继续执行python setup.py install
    # 会发现可以看到success了。

    命令行的格式的解释如下表所示:

    cl optionsargdefault
    Usage help -h --
    List Themes -l --
    Theme Name to Install -t --
    Code Font -f --
    Code Font-Size -fs 11
    Notebook Font -nf --
    Notebook Font Size -nfs 13
    Text/MD Cell Font -tf --
    Text/MD Cell Fontsize -tfs 13
    Pandas DF Fontsize -dfs 9
    Output Area Fontsize -ofs 8.5
    Mathjax Fontsize (%) -mathfs 100
    Intro Page Margins -m auto
    Cell Width -cellw 980
    Line Height -lineh 170
    Cursor Width -cursw 2
    Cursor Color -cursc --
    Alt Prompt Layout -altp --
    Alt Markdown BG Color -altmd --
    Alt Output BG Color -altout --
    Style Vim NBExt* -vim --
    Toolbar Visible -T --
    Name & Logo Visible -N --
    Reset Default Theme -r --
    Force Default Fonts -dfonts --
    各种主题展示:
    plotting style

    image

    markdown/equations

    image

    pandas dataframes

    image

    command palette

    image

    oceans16 syntax

    image

    grade3 syntax

    image

    onedork syntax

    image

    chesterish syntax

    image

     
  • 相关阅读:
    Android Overlay学习
    为WinForm combox控件增加自动完成功能
    职业理想
    How to become a hacerk.黑客
    .net程序员常用网站
    面向对象设计原则
    net开源cms系统
    如何:禁用 Windows 窗体 DataGridView 控件的按钮列中的按钮(摘录)
    计算机编码(百度百科)
    .net winform 从资源文件中引用图片资源
  • 原文地址:https://www.cnblogs.com/lvpengbo/p/8624638.html
Copyright © 2011-2022 走看看