答案是:需先定位报错类型——若含“puccinialin”或“no matching distribution”,说明python≤3.8不兼容,应升级至3.9+;若报“soft_unicode from markupsafe”,则执行pip install markupsafe==2.0.1降级;若出现路径错误或subprocess失败,需启用长路径支持或安装编译工具。

pip install jupyter notebook 报错,大概率不是命令写错了,而是环境或依赖链出了问题。直接重试或加 --force-reinstall 通常没用,得先定位错误类型。
看报错信息里有没有 “puccinialin” 或 “no matching distribution”
这是 Python 版本太低的典型信号——puccinialin 是 Jupyter 依赖链中某个新包(如 pyproject.toml 构建后端),Python 3.8 及更早版本不支持其构建方式。
- 检查当前 Python 版本:
python --version,若 ≤3.8,必须升级 - 推荐做法:用
conda create -n jup39 python=3.9新建环境,再conda activate jup39后运行pip install notebook - 不用 conda 的话,至少用 Python 3.9+ 官方安装包重装,别指望
pyenv或系统自带的旧版能硬扛
报错含 “OSError: [Errno 2] No such file or directory” 路径特别长
Windows 上常见于 Microsoft Store 版 Python(路径带 PythonSoftwareFoundation.Python.3.xx_qbz5n2kfra8p0),触发系统默认 260 字符路径限制。
- 临时解法:在 PowerShell 中执行
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1,重启终端 - 根治法:卸载 Microsoft Store 版 Python,改用 python.org 下载的 Windows x86-64 MSI 安装包
- 验证是否生效:运行
python -c "import tempfile; print(tempfile.gettempdir())",看路径是否明显缩短
报错是 “ImportError: cannot import name ‘soft_unicode’ from ‘markupsafe’”
这是 markupsafe 版本越界导致的——Jupyter(尤其搭配 nbextensions)需要 markupsafe,但 pip 默认装最新版(如 2.1.5+)。
- 执行
pip install markupsafe==2.0.1强制降级(注意是双等号) - 别用
--upgrade,它会把刚降的又顶回去 - 如果已装了 nbextensions,建议一并重装:
pip install --force-reinstall jupyter_contrib_nbextensions
报错末尾写着 “subprocess-exited-with-error” 却没具体包名
说明 pip 在调用构建工具(如 build、setuptools)时失败,常见于缺失编译环境或 wheel 不兼容。
- 先升级构建工具:
pip install --upgrade build setuptools wheel - Windows 用户补装 Visual Studio Build Tools(或至少安装“C++ build tools”工作负载)
- Linux/macOS 用户确认
gcc和python3-dev(Ubuntu/Debian)或python3-devel(CentOS/RHEL)已就位 - 仍失败?换国内源重试:
pip install notebook -i https://pypi.tuna.tsinghua.edu.cn/simple
pip 指向的是用户级安装,而 Jupyter 启动时用的是系统级 Python。查 which python 和 python -c "import sys; print(sys.executable)" 对不上,就先别碰 install 命令。











