通过CMD安装Jupyter失败,安装Rust后仍遇pywinpty编译错误求助
问题1:缺少Rust工具链引发元数据生成失败
error: subprocess-exited-with-error
× 准备元数据(pyproject.toml)未成功运行。
│ 退出代码:1
╰─> [6行输出]
Cargo, the Rust package manager, is not installed or is not on PATH.
This package requires Rust and Cargo to compile extensions. Install it through the system's package manager or via https://rustup.rs/
Checking for Rust toolchain....
[end of output]
note: 此错误源自子进程,大概率并非pip的问题。
error: metadata-generation-failed
× 生成包元数据时遇到错误。
╰─> 详见上方输出。
note: 这是上述包的问题,而非pip的问题。
hint: 详见上方详情。
解决方法
安装Rust工具链:
- 打开CMD,执行命令完成安装:
rustup-init.exe - 安装结束后重启CMD,确保Cargo路径生效。
问题2:安装Rust后pywinpty编译失败
ERROR: Failed building wheel for pywinpty
Failed to build pywinpty
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pywinpty)
解决方法
针对该问题可尝试以下方案:
- 安装Visual Studio构建工具:pywinpty依赖Windows C编译环境,安装Visual Studio时勾选「桌面开发使用C」组件,确保包含MSVC编译器、Windows SDK等工具,完成后重启CMD。
- 使用预编译wheel包:下载与你的Python版本、系统架构匹配的pywinpty预编译wheel文件,通过pip直接安装:
pip install pywinpty-<版本号>-<平台标识>.whl - 升级工具链后重试:先更新pip、setuptools和wheel到最新版本,再重新安装Jupyter:
pip install --upgrade pip setuptools wheelpip install jupyter
内容的提问来源于stack exchange,提问作者RAJIBA KUMAR MAHARANA

