electron-builder: Exit code: ENOENT. spawn /usr/bin/python error after updating macOS
- Electron-Builder Version: 22.14.13
- Node Version: 16.13.2
- Electron Version: 17.1.2
- Electron Type (current, beta, nightly): current
- Target: universal
I recently updated my MacBook Air M1 (macOS Monterey) to 12.3 and started receiving this error when running “electron-builder”:
• electron-builder version=22.14.13 os=21.4.0
• loaded configuration file=package.json ("build" field)
• writing effective config file=dist/builder-effective-config.yaml
• packaging platform=darwin arch=arm64 electron=17.1.2 appOutDir=dist/mac-arm64
• default Electron icon is used reason=application icon is not set
• skipped macOS application code signing reason=cannot find valid "Developer ID Application" identity or custom non-Apple code signing certificate, it could cause some undefined behaviour, e.g. macOS localized description not visible, see https://electron.build/code-signing allIdentities= 0 identities found
Valid identities only
0 valid identities found
• building target=macOS zip arch=arm64 file=dist/my-app-0.2.0-arm64-mac.zip
• building target=DMG arch=arm64 file=dist/my-app-0.2.0-arm64.dmg
• Detected arm64 process, HFS+ is unavailable. Creating dmg with APFS - supports Mac OSX 10.12+
• building block map blockMapFile=dist/my-app-0.2.0-arm64-mac.zip.blockmap
⨯ Exit code: ENOENT. spawn /usr/bin/python ENOENT failedTask=build stackTrace=Error: Exit code: ENOENT. spawn /usr/bin/python ENOENT
at /Users/helder/Documents/patientdiary/node_modules/builder-util/src/util.ts:133:18
at exithandler (node:child_process:404:5)
at ChildProcess.errorhandler (node:child_process:416:5)
at ChildProcess.emit (node:events:390:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
at onErrorNT (node:internal/child_process:477:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 41
- Comments: 23
Commits related to this issue
- Update electron-builder to fix failed to build https://github.com/electron-userland/electron-builder/issues/6726 This commit also updated the others packages — committed to Naozumi520/Remedy by deleted user 2 years ago
- Upgrades electron builder to deal with macOS issue https://github.com/electron-userland/electron-builder/issues/6726 — committed to EmotionCognitionLab/pvs by noah10 2 years ago
- Upgrade electron-builder Summary: Fix build on new MacOS https://github.com/electron-userland/electron-builder/issues/6726 Reviewed By: passy Differential Revision: D35211540 fbshipit-source-id: f... — committed to facebook/flipper by aigoncharov 2 years ago
- dep(npm): bump electron-builder@^23.0.3 - Fixes "ENOENT. spawn /usr/bin/python error" (electron-userland/electron-builder#6726) — committed to erisu/cordova-electron by erisu 2 years ago
- dep(npm): bump electron-builder@^23.0.3 - Fixes "ENOENT. spawn /usr/bin/python error" (electron-userland/electron-builder#6726) — committed to erisu/cordova-electron by erisu 2 years ago
- dep(npm): bump electron-builder@^23.0.3 - Fixes "ENOENT. spawn /usr/bin/python error" (electron-userland/electron-builder#6726) — committed to erisu/cordova-electron by erisu 2 years ago
- dep(npm): bump electron-builder@^23.0.3 - Fixes "ENOENT. spawn /usr/bin/python error" (electron-userland/electron-builder#6726) — committed to erisu/cordova-electron by erisu 2 years ago
- dep(npm): bump electron-builder@^23.0.3 (#227) - Fixes "ENOENT. spawn /usr/bin/python error" (electron-userland/electron-builder#6726) — committed to apache/cordova-electron by erisu 2 years ago
- Attempt to fix MacOS failing build Upgrade electron-builder to see if this fixes the issue. According to https://github.com/electron-userland/electron-builder/issues/6726 — committed to workadventure/workadventure by moufmouf 2 years ago
- fix: electron-builder fails to build cf. https://github.com/electron-userland/electron-builder/issues/6726 — committed to ottijp/markuprev by ottijp 2 years ago
- fix: mac打包报错”Exit code: ENOENT. spawn /usr/bin/python“,参考https://github.com/electron-userland/electron-builder/issues/6726#issuecomment-1164130245 — committed to buxianshan/git-repos by buxianshan a year ago
- Update electron-builder to 23.0.2 This fixes the error with building in macos more info here: https://github.com/electron-userland/electron-builder/issues/6726 — committed to NeonGamerBot-QK/Annotationapp by NeonGamerBot-QK a year ago
- build: override electron-builder ref: https://github.com/electron-userland/electron-builder/issues/6726#issuecomment-1164130245 — committed to gimKondo/sound-of-cthulhu by gimKondo a year ago
- Fix macOS desktop build failure in CI The GitHub-hosted runners began experiencing issues while building macOS desktop distributions, exclusively affecting the macOS environment. The Ubuntu and Windo... — committed to undergroundwires/privacy.sexy by undergroundwires a year ago
- Electron/Builder Upgrades I also updates the `package-lock.json` to the v3 format. Now the app compiles again, too! Looks like I ran into this issue with Electron-Builder here, I'm pretty sure. http... — committed to Offroaders123/Electron-Text-Editor by Offroaders123 9 months ago
- Fix macOS desktop build failure in CI The GitHub-hosted runners began experiencing issues while building macOS desktop distributions, exclusively affecting the macOS environment. The Ubuntu and Windo... — committed to LarrMarburger/privacy.sexy by LarrMarburger a year ago
You are right, upgrading to 23.0.2 fixed this issue.
I had searched for this for some time but I couldn’t find anything, thanks for the help!
npm install electron-builder@23.0.2I’m investigating this issue right now since it’s blocking my work. Here’s what I’ve learned:
builder-utilis trying to call python because the packagedmg-builderuses python scriptsPYTHON_PATHto overwrite the default of/usr/bin/python, however:dmg-builderuses thereloadmodule, which is only available builtin in Python 2So presumably, setting
PYTHON_PATHto a python2 installation could work around this issue. I’ll be trying that next.I also had this issue when using
"vue-cli-plugin-electron-builder": "^2.1.1"and I already overrode the electron-builder in my package file to23.03but it didn’t help."electron-builder": "^23.1.0"is working for me. My vue plugin is still running on 2.1.1.The whole snippet
As on my Mac, It works after next steps
which pythonin terminal after reinstall python2, It will be like/Library/Frameworks/Python.framework/Versions/2.7/bin/python/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonreplace “/usr/bin/python” in dmg.jsFYI, this may be a dupe of #6606
This should work 😁. Go to node_modules/dmg-builder/out/dmg.js. In “dmg.js” file, search replace “usr/bin/python” to “usr/bin/python2”.
*Note: Python v2 must be installed, and check if this directory exists by pressing “sudo cd usr/bin/python2”.
I ended up just updating
electron-builder, so I never finished testingPYTHON_PATH.@hjMaGitHub , it looks like
vue-cli-plugin-electron-builderis still potentially using an old version ofelectron-builder. If you use Yarn, you can use selective dependency resolutions to force that module to use the newerelectron-builder. I don’t know how to do that with NPMI had just
"vue-cli-plugin-electron-builder": "~2.1.1"installed. After adding"electron-builder": "^23.0.3",as additional dependency the error was gone and build works.if you use yarn,after install python2.7.18 and fix the python’s path, you can add this code in package.json to fix it “dependencies”: { … } “devDependencies”: { … } “resolutions”: { “vue-cli-plugin-electron-builder/electron-builder”: “^23.0.3” }
yarn is ok, I’m not try it in npm
2024 and none of the mentioned solutions above worked for me. For anyone out there still facing this issue till today. If you are on Apple silicon M1/M2 or M3, you might want to do this.
PS: i am using the eletron-builder in a vuejs app, just FYI
Problem: Firstly, this is a python problem like mentioned above, however since MacOS doesn’t ship with default python anymore it’s an issue. It seems like the
"vue-cli-plugin-electron-builder": "~2.1.1"package hasn’t been updated yet with the latest builder version which as of today is"electron-builder": "^24.9.1",. and it appears the versionvue-cli-plugin-electron-builderis not yet compatible with the the new arm64 architecture.Solution:
electron-builderwithnpm i electron-builderWorks like charm✨
PS: Another untested solution which could theoretically work is, you should find a way to install python 2.x (I think) and update the environment variables so it can find it in the path
usr/bin/pythonfix it for npm8: “overrides”: { “vue-cli-plugin-electron-builder”: { “electron-builder”: “^23.0.3” } } not resolutions, npm is getting bad
npm (native) solution to this are npm overrides. See example here.