【问题标题】:Problems setting up a new theme in Ipython?在 Ipython 中设置新主题时出现问题?
【发布时间】:2015-01-14 23:07:49
【问题描述】:

我想为 Ipython 笔记本使用另一个主题,所以我关注了这个instructions 问题是我在 OSX 中,我没有 wget,我安装了它。有人可以帮我在黑暗主题中设置 ipython 笔记本吗?我试过这个:

brew /Users/user/.ipython/profile_notebooks/static/custom/custom.css
https://raw.githubusercontent.com/nsonnad/base16-ipython-notebook/master/base16-ocean-dark.css

【问题讨论】:

    标签: python macos python-2.7 ipython ipython-notebook


    【解决方案1】:

    您可以使用curl 或手动下载主题来完成。我已经给出了以下两个选项的步骤。

    使用以下命令创建自定义配置文件:

    ipython profile create ocean
    

    使用以下命令将默认样式表 custom.css 的内容替换为所需主题的内容

    使用 curl:

    curl -o `ipython locate profile ocean`/static/custom/custom.css https://raw.githubusercontent.com/nsonnad/base16-ipython-notebook/master/base16-ocean-dark.css
    

    通过指定自定义配置文件来启动 IPython 笔记本,例如

    ipython notebook --profile=ocean
    

    替代方案:

    如果您无法使用curl 下载,您只需下载base16-ocean-dark.css 并在您创建的配置文件的自定义目录中替换custom.css

    找到配置文件目录:

    ipython locate profile ocean
    

    进入其static/custom目录,将custom.css的内容替换为下载的css文件的内容。 如上所示,通过指定自定义配置文件来启动 IPython 笔记本。

    【讨论】:

      【解决方案2】:

      Amit 的答案不适合 ipython=>4.0,因为 jupyter 现在已经与它分开了。

      你可以试试jupyter-themes。 适合ipython=>4.0,安装更简单。

      安装 jupyter 主题

      $ pip install --upgrade jupyterthemes
      

      选择一个主题并安装

      # list themes (located in ~/.jupyter-themes)
      $ jt -l
      
      # install theme (-t) for jupyter nb
      # theme names: oceans16 | grade3 | space-legos
      $ jt -t grade3
      
      # install a theme (-t) with toolbar (-T) enabled
      $ jt -T -t grade3
      
      # install a theme (-t) and set font-size (-f), default value is 11
      $ jt -f 12 -t grade3
      
      # reset (-r) to default for jupyter theme
      $ jt -r
      

      【讨论】:

      • 嘿,我按照你的建议做了,但是得到一个问题“主题等级 3 未找到。可用:”显然下面是空列表。我查看了jupyterthemes/__init__.py,当get_theme() 方法返回不包含grade3 的主题列表时出现此错误。但老实说,我感觉它看起来在错误的目录中。同时,我无法从 git 安装它,所以我从 zip 文件安装它 - 不确定是否有任何区别。
      • @llya 您在用户主页中有.jupyter.jupyter-themes 文件夹吗?在.jupyter 下需要一个custom 文件夹。 PS:我用的是windows,可能其他操作系统会有一些不同。
      • 我也在使用 Windows。我那里只有.jupyter 文件夹,只有一个文件migrated,没有扩展名。
      • 我在那里创建了.jupyter-themes文件夹(你需要创建一个文件夹.jupyter-themes.,最后添加一个点,它被Windows资源管理器删除),并在那里复制.css文件来自 git。然后它起作用了。我不明白这个文件夹是如何自动创建的。
      • @Ilya 也许你应该向 jupyter-themes 发布一个问题。在我的情况下,只需安装它就可以了
      【解决方案3】:

      我在 pypi 中添加了 jupyter-themes,名称为 jupyterthemes。

      要安装最新版本:

      #uninstall any old versions
      pip uninstall jupyter-themes 
      #install the latest version (no hyphen)
      pip install jupyterthemes
      

      希望这能解决人们在主题未出现时遇到的任何问题 (@llya)。

      【讨论】:

        猜你喜欢
        • 2018-03-16
        • 2022-07-05
        • 1970-01-01
        • 2021-10-03
        • 2015-05-16
        • 2013-03-17
        • 2020-11-08
        • 1970-01-01
        相关资源
        最近更新 更多