用 conda 安装 jupyter-themes: 修改 ju
安装方法
-
安装
若jupyter notebook是conda安装的,强烈建议用conda安装jupyterthemes,不然若用pip安装jupyterthemes,会出现多种依赖不匹配
conda install -c conda-forge jupyterthemes
若jupyter notebook是pip安装的,则
pip install jupyterthemes
-
配置
终端下输入以下命令
jt -t gruvboxd -T -N
意为使用 gruvboxd 主题,打开顶部工具栏(Toolbar),显示文件名(Name)
运行过程中可能会返回报错如下,这说明已经别的用户安装了jupyterthemes,并重建了
/tmp/yacctab.py
,故你无法重写这个文件,这并不运行你使用jupyter notebook的配色。你的配色设置,保存到$HOME/.jupyter/custom/
,不和他的配色设置冲突。WARNING: Couldn't create 'yacctab'. [Errno 13] Permission denied: '/tmp/yacctab.py'
WARNING: Couldn't create 'yacctab'. [Errno 13] Permission denied: '/tmp/yacctab.py' -
配置文件
配置文件保存到了
$HOME/.jupyter/custom/
,下是四个配置和依赖文件current_theme. txt, custom.css, custom.js, fonts/
,之后每次执行jupyter notebook
启动notebook时,会加载此配置,看见你要的主题。
依赖不匹配怎么解决
若jupyter notebook是conda安装,却用安装pip安装jupyterthemes,会出现多种依赖不匹配,最终如下装一圈依赖,才能安装成功
conda upgrade notebook libsodium
pip install jupyterthemes
pip install --upgrade --user nbconvert
pip install --upgrade ipykernel
以下是各个依赖不匹配的详解:
Found existing installation: terminado 0.6
执行pip install jupyterthemes
时报错
notebook 5.7.6 has requirement jupyter-core>=4.4.0, but you'll have jupyter-core 4.3.0 which is incompatible.
Installing collected packages: lesscpy, terminado, pyzmq, jupyter-client, prometheus-client, Send2Trash, notebook, jupyterthemes
Found existing installation: terminado 0.6
Cannot uninstall 'terminado'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
这是因为,上述操作中pip自动更新了notebook,但这个notebook是用conda而非pip装的,故依赖项terminado不对
解决方法:
conda upgrade notebook
而后可正常安装
pip install jupyterthemes
ImportError: libsodium.so.23
执行jupyter notebook
,报错
ImportError: libsodium.so.23: cannot open shared object file: No such file or directory
这是由于jupyterthemes
依赖的libsodium
没有更新
解决办法:
conda update libsodium
# 或
conda install -c conda-forge libsodium
ModuleNotFoundError: No module named 'nbconvert.exporters.base'
运行notebook时,用浏览器成功打开notebook的目录网页,但无法打开/新建python3 的 notebook文件,命令行下报错
ModuleNotFoundError: No module named 'nbconvert.exporters.base'
[E 20:28:58.544 NotebookApp]
这是因为,这是由于jupyterthemes
依赖的nbconvert
没有更新
解决办法:
pip install --upgrade --user nbconvert
然后将$USER/.local/bin
添加到PATH,即可实现上述运行
ERROR:tornado.general: Uncaught exception in zmqstream callback
运行notebook时,用浏览器成功打开notebook的目录网页,能成功打开/新建python3 的 notebook文件,但点运行,迟迟不运行,命令行下报错
ERROR:tornado.general: Uncaught exception in zmqstream callback
这是因为,这是由于jupyterthemes
依赖的ipykernel
没有更新
解决办法:
pip install --upgrade ipykernel