You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装gpu.js时出现gl模块node-gyp编译错误求助

解决gpu.js安装时因Python 3.12缺失distutils导致node-gyp编译失败的问题

问题根源

Python 3.12正式移除了distutils模块,而gpu.js依赖的gl模块编译需要用到node-gyp,当前node-gyp尚未完全适配Python 3.12的这一变更,因此触发编译失败。

可行解决方案

  • 降级Python到3.11及以下版本
    利用版本管理工具(如pyenv)切换到兼容的Python版本:

    1. 安装pyenv(MacOS):brew install pyenv
    2. 安装Python 3.11.x:pyenv install 3.11.6
    3. 设置全局默认版本:pyenv global 3.11.6,或在项目目录下设置局部版本:pyenv local 3.11.6
    4. 验证版本:python --version,确认显示为3.11.x后重新执行安装命令。
  • 手动为Python 3.12安装distutils

    • Linux(Debian/Ubuntu):sudo apt-get install python3-distutils
    • MacOS:尝试通过brew安装brew install python3-distutils,若不可用,可使用conda安装:conda install distutils
  • 指定node-gyp使用的Python版本(无需全局降级)

    • npm:临时配置后安装:
      npm config set python /path/to/python3.11
      npm install gpu.js
      
      或安装时直接指定:npm install gpu.js --python=/path/to/python3.11
    • Yarn:配置后安装:
      yarn config set python /path/to/python3.11
      yarn add gpu.js
      
    • Bun:通过环境变量指定:PYTHON=/path/to/python3.11 bun add gpu.js
  • 补全node-gyp依赖环境
    MacOS需确保安装Xcode命令行工具:xcode-select --install,安装完成后可执行npx node-gyp configure验证环境是否正常。

内容的提问来源于stack exchange,提问作者LmanTW

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 18:39:59