应使用包名jupyterthemes(无连字符)安装,pip命令为pip install jupyterthemes,conda命令为conda install -c conda-forge jupyterthemes,装错包名会导致modulenotfounderror或jt命令未找到。

直接用 pip 或 conda 装 jupyterthemes 就行,别装错包名(不是 jupyter-theme 或 jupyter-themes 带连字符的其他变体)。
安装命令必须用 jupyterthemes(无连字符)
这个工具的 PyPI 包名是 jupyterthemes,少一个横线、多一个横线都会报错或装错。常见错误现象:ModuleNotFoundError: No module named 'jupyterthemes' 或 jt 命令未找到,大概率是包名输错了。
- 用 pip:运行
pip install jupyterthemes - 用 conda:运行
conda install -c conda-forge jupyterthemes - 升级时也得用同样包名:
pip install --upgrade jupyterthemes
装完后 jt 命令没反应?检查 PATH 和 shell 缓存
安装成功但终端不识别 jt,通常不是安装失败,而是 shell 没刷新可执行路径。Windows 用户尤其容易卡在这一步。
- 关闭当前终端,新开一个再试
- macOS/Linux 用户可执行
hash -d jt或source ~/.zshrc(或~/.bashrc)刷新环境 - 如果用的是 Anaconda Prompt,确保它已激活 base 环境(或你安装时所处的环境)
- 验证是否生效:运行
jt -h,有帮助输出即成功
主题安装依赖 lesscpy,出错时别手动装它
jupyterthemes 内部依赖 lesscpy 编译 .less 主题文件。某些旧系统或 Python 版本下,lesscpy 安装可能失败,表现为 ImportError: No module named 'lesscpy' 或主题应用时报 CSS 编译错误。
- 不要单独
pip install lesscpy—— 它的 0.15.x 版本与 Python 3.12+ 不兼容 - 正确做法:升级
jupyterthemes到最新版(2026 年当前为 0.21.x),它已内置适配逻辑,自动跳过或降级依赖 - 若仍失败,临时方案是加
--no-deps后重装:pip install --no-deps jupyterthemes,再手动装兼容版pip install lesscpy==0.14.2
确认安装位置和权限问题
在虚拟环境中装了却全局调用不到,或提示 Permission denied,说明环境隔离或权限没对齐。
- 运行
which jt(macOS/Linux)或where jt(Windows)看命令在哪 —— 应该落在当前 Python 环境的bin/或Scripts/目录下 - 如果用 conda 环境,确保没混用 pip 和 conda(比如在 conda env 里用 pip 装,又在 base 里调用)
- Mac M1/M2 用户遇到
Operation not permitted,试试加--user参数:pip install --user jupyterthemes
真正麻烦的不是装不上,而是装了但 jt -l 列不出主题,或 jt -t xxx 后刷新页面没变化 —— 那基本是缓存或 Jupyter 配置路径没对,不是安装环节的问题。











