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

Most upvoted comments

FYI, this may be a dupe of #6606

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.2

I’m investigating this issue right now since it’s blocking my work. Here’s what I’ve learned:

  • builder-util is trying to call python because the package dmg-builder uses python scripts
  • You can set the environment variable PYTHON_PATH to overwrite the default of /usr/bin/python, however:
  • dmg-builder uses the reload module, which is only available builtin in Python 2

So presumably, setting PYTHON_PATH to 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 to 23.03 but 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

"devDependencies": {
    "electron": "^19.0.4",
    "vue-cli-plugin-electron-builder": "^2.1.1",
  },
"overrides": {
    "vue-cli-plugin-electron-builder": {
      "electron-builder": "^23.1.0"
    }
  }

python2

As on my Mac, It works after next steps

  1. find the python2 real path use which python in terminal after reinstall python2, It will be like /Library/Frameworks/Python.framework/Versions/2.7/bin/python
  2. open /node_modules/dmg-builder/out/dmg.js In your project
  3. Use /Library/Frameworks/Python.framework/Versions/2.7/bin/python replace “/usr/bin/python” in dmg.js
  4. Save it

FYI, 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”.

  • The reason why this error exists “Exit code: ENOENT. spawn /usr/bin/python” is because “ENOENT” means no existing directory. The version of the python cant be found.

@scowalt did you manage to make it work by setting the PYTHON_PATH? I can’t update electron-builder because it’ll break other things

I ended up just updating electron-builder, so I never finished testing PYTHON_PATH.


@hjMaGitHub , it looks like vue-cli-plugin-electron-builder is still potentially using an old version of electron-builder. If you use Yarn, you can use selective dependency resolutions to force that module to use the newer electron-builder. I don’t know how to do that with NPM

I 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 version vue-cli-plugin-electron-builder is not yet compatible with the the new arm64 architecture.

Solution:

  • install electron-builder with npm i electron-builder
  • update your package.json with the code below. This forces override via npm:
    // other dev dependencies
    "vue-cli-plugin-electron-builder": "~2.1.1"
  },
  "overrides": {
    "vue-cli-plugin-electron-builder": {
      "electron-builder": "^23.0.6"
    }
  }

Works 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/python

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

fix it for npm8: “overrides”: { “vue-cli-plugin-electron-builder”: { “electron-builder”: “^23.0.3” } } not resolutions, npm is getting bad

yarn is ok, I’m not try it in npm

npm (native) solution to this are npm overrides. See example here.