Windows下安装mm-game库时出现building wheels错误求助
问题描述
我在Windows系统下用VSCode开发Python项目,尝试安装mm-game库时遇到以下问题:
- 使用
pip install mm-game安装时,出现无法build wheel的错误,核心报错为找不到nmake工具,且CMAKE_CXX_COMPILER未设置 - 使用
conda install mm-game安装时,提示PackagesNotFoundError,当前conda频道无此包
pip安装错误日志
pip install mm-game Collecting mm-game Using cached mm_game-0.0.4.tar.gz (9.6 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: mm-game Building wheel for mm-game (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for mm-game (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [19 lines of output] *** scikit-build-core 0.10.7 using CMake 3.31.0 (wheel) *** Configuring CMake... 2024-11-22 16:53:34,289 - scikit_build_core - WARNING - Can't find a Python library, got libdir=None, ldlibrary=None, multiarch=None, masd=None loading initial cache file C:\Users\jaspe\AppData\Local\Temp\tmp1waewgfv\build\CMakeInit.txt -- Building for: NMake Makefiles CMake Error at CMakeLists.txt:7 (project): Running 'nmake' '-?' failed with: no such file or directory CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred! *** CMake configuration failed [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for mm-game Failed to build mm-game ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (mm-game)
conda安装错误日志
Channels: - defaults Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: failed PackagesNotFoundError: The following packages are not available from current channels: - mm-game Current channels: - defaults - https://repo.anaconda.com/pkgs/main - https://repo.anaconda.com/pkgs/r - https://repo.anaconda.com/pkgs/msys2 To search for alternate channels that may provide the conda package you're looking for, navigate to https://anaconda.org and use the search bar at the top of the page.
解决方案
1. 处理conda安装问题
mm-game未发布到conda默认频道,无法通过conda直接安装,只能使用pip方式安装。
2. 解决pip构建失败问题
报错核心是Windows系统缺少C++编译环境和CMake构建工具,按以下步骤操作:
- 安装Visual Studio构建工具
- 打开Visual Studio安装程序(若未安装,先安装该程序)
- 在“工作负载”选项卡中,勾选**“使用C++的桌面开发”**
- 在右侧“安装详细信息”中,确保勾选以下组件:
- MSVC vxxx - VS 20xx C++ x64/x86生成工具(xxx对应你的VS版本)
- Windows 10/11 SDK
- C++ CMake工具 for Windows
- 点击“安装”,等待安装完成。
- 在正确的命令行环境中执行pip安装
- 安装完成后,打开“开始菜单”,找到Visual Studio文件夹,启动**“x64本机工具命令提示符 for VS 20xx”**(根据你的VS版本选择)
- 在该命令行中,切换到你的Python项目环境(若使用虚拟环境,先激活)
- 执行命令:
pip install mm-game
- 验证安装
打开Python终端,执行import mm_game,无报错则安装成功。
内容的提问来源于stack exchange,提问作者Jasper Blume
相关产品推荐
相关产品推荐

