夜听城嚣 夜听城嚣
首页
  • 学习笔记

    • 《JavaScript高级程序设计》
    • 前端基建与架构
  • 专题分享

    • Git入门与开发
    • 前端面试题汇总
    • HTML和CSS知识点
  • 项目实践
  • 抓包工具
  • 知识管理
  • 工程部署
  • 团队规范
bug知多少
  • 少年歌行
  • 青年随笔
  • 文海泛舟
  • 此事躬行

    • 项目各工种是如何协作的
    • TBA课程学习
收藏

dwfrost

前端界的小学生
首页
  • 学习笔记

    • 《JavaScript高级程序设计》
    • 前端基建与架构
  • 专题分享

    • Git入门与开发
    • 前端面试题汇总
    • HTML和CSS知识点
  • 项目实践
  • 抓包工具
  • 知识管理
  • 工程部署
  • 团队规范
bug知多少
  • 少年歌行
  • 青年随笔
  • 文海泛舟
  • 此事躬行

    • 项目各工种是如何协作的
    • TBA课程学习
收藏
  • chrome控制台怎么复制对象
  • 小程序键盘弹起后顶起自定义导航问题
  • node子进程如何输出和关闭
  • 代理域名后webpack热更新失效及解决
  • 小程序scroll-view隐藏滚动条
  • npm包相关
  • electron下载慢解决
  • electron开发踩坑
  • mac升级后git找不到
  • electron打包找不到python
    • 安装imagemin-mozjpeg失败
    • 开发中的bug类型踩坑
    • 云端web项目开发踩坑
    • 如何快速定位bug
    • bug知多少
    frost
    2022-11-03

    electron打包找不到python

    在 mac 升级后,出现过 git 找不到的问题。后来又在 electron 打包的时候出现了 python 找不到的问题。

    # 问题

    在 electron 打包 mac 版本,出现报错。

      ⨯ Exit code: 1. Command failed: which python
      failedTask=build stackTrace=Error: Exit code: 1. Command failed: which python
    
    1
    2

    根据这篇博文 (opens new window),尝试从源码入手,找到node_modules/dmg-builder/out/dmg.js,找到如下代码:

    const executePython = async (execName) => {
      let pythonPath = process.env.PYTHON_PATH
      if (!pythonPath) {
        pythonPath = (await builder_util_1.exec('which', [execName])).trim()
      }
      await builder_util_1.exec(pythonPath, [path.join(dmgUtil_1.getDmgVendorPath(), 'dmgbuild/core.py')], {
        cwd: dmgUtil_1.getDmgVendorPath(),
        env,
      })
    }
    try {
      await executePython('python3')
    } catch (error) {
      await executePython('python')
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15

    发现它其实是兼容 python2 和 python3 的,但是还是报错了,于是加上日志。

    try {
      console.log('python3')
      await executePython('python3')
    } catch (error) {
      console.log('python', error)
      await executePython('python')
    }
    
    1
    2
    3
    4
    5
    6
    7

    重新执行 build,截到报错。

    python Error: Exit code: 1. Command failed: /usr/bin/python3 /Users/macbookpro/Documents/app/test/demos/electron-demos/mini-cup/node_modules/dmg-builder/vendor/dmgbuild/core.py
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    
    1
    2

    提示找不到xcrun,在 stackoverflow 找到类似的问题(才发现就是先前找过的)。安装最新的 Command_Line_Tools_for_Xcode 后重启电脑,就可以正常打包了。

    stackoverflow issue (opens new window)

    上次更新: 2022/11/03, 18:40:54
    mac升级后git找不到
    安装imagemin-mozjpeg失败

    ← mac升级后git找不到 安装imagemin-mozjpeg失败→

    最近更新
    01
    提交代码时修改commit消息
    04-09
    02
    如何快速定位bug
    02-20
    03
    云端web项目开发踩坑
    08-25
    更多文章>
    Theme by Vdoing | Copyright © 2021-2025 dwfrost | 粤ICP备2021118995号
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式
    ×