mac系统electron项目打包出现:Error: Exit code: ENOENT. spawn /usr/bin/python ENOENT

    mac系统下,electron项目打包,好像需要python可执行程序,如果找不到就报这个错误,而且python版本需要2.7版本。

    我的系统不知道怎么回事,因为已经安装了python2.7.11版本,我就想着ln -s /path/to/python /usr/bin/python做个软链接,结果系统报错:Read-only file system。看来需要找别的办法,经过查找,发现可以设置环境变量PYTHON_PATH就可以了。

export PYTHON_PATH=/usr/local/Cellar/python/2.7.11/bin/python

    将python可执行程序的路径设置为PYTHON_PATH,然后让他生效。最后执行npm run electron:build,就构建成功了。 

    据我所知,PYTHON_PATH这个变量是设置加载python库的变量,很多地方会将通过pip install安装的python库的位置site-packages目录设置在这个变量上。不知道为什么还可以设置成python可执行程序的路径,竟然可以解决这个问题。

    之前在windows系统上安装mingw64,用到里面的gcc命令,最后命令行下报错,说是很多动态库缺失,其实那些动态库都在mingw64/bin目录下,和gcc在同一个目录,但是命令行下却报错,后来根据网上的建议,把mingw64/bin目录加入Path环境变量,竟然解决了动态库缺失的问题。

    有一些环境变量的设置真的很奇怪。

pnpm run package > hotpot-financial-system@1.0.0 prepackage E:\安装包\243243323906 > taskkill /f /im electron.exe >nul 2>&1 & rimraf dist/electron > hotpot-financial-system@1.0.0 package E:\安装包\243243323906 > electron-builder • electron-builder version=24.13.3 os=10.0.26100 • loaded configuration file=package.json ("build" field) • writing effective config file=dist\electron\builder-effective-config.yaml • skipped dependencies rebuild reason=npmRebuild is set to false • packaging platform=win32 arch=ia32 electron=28.2.0 appOutDir=dist\electron\win-ia32-unpacked • default Electron icon is used reason=application icon is not set ⨯ Get "https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z": dial tcp 20.205.243.166:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. github.com/develar/app-builder/pkg/download.(*Downloader).follow.func1 /Volumes/data/Documents/app-builder/pkg/download/downloader.go:206 github.com/develar/app-builder/pkg/download.(*Downloader).follow /Volumes/data/Documents/app-builder/pkg/download/downloader.go:234 github.com/develar/app-builder/pkg/download.(*Downloader).DownloadNoRetry /Volumes/data/Documents/app-builder/pkg/download/downloader.go:128 github.com/develar/app-builder/pkg/download.(*Downloader).Download /Volumes/data/Documents/app-builder/pkg/download/downloader.go:112 github.com/develar/app-builder/pkg/download.DownloadArtifact /Volumes/data/Documents/app-builder/pkg/download/artifactDownloader.go:107 github.com/develar/app-builder/pkg/download.downloadFromGithub /Volumes/data/Documents/app-builder/pkg/download/tool.go:63 github.com/develar/app-builder/pkg/download.DownloadWinCodeSign /Volumes/data/Documents/app-builder/pkg/download/tool.go:58 github.com/develar/app-builder/pkg/rcedit.editResources /Volumes/data/Documents/app-builder/pkg/rcedit/rcedit.go:30 github.com/develar/app-builder/pkg/rcedit.ConfigureCommand.func1 /Volumes/data/Documents/app-builder/pkg/rcedit/rcedit.go:25 github.com/alecthomas/kingpin.(*actionMixin).applyActions /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/actions.go:28 github.com/alecthomas/kingpin.(*Application).applyActions /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:557 github.com/alecthomas/kingpin.(*Application).execute /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:390 github.com/alecthomas/kingpin.(*Application).Parse /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:222 main.main /Volumes/data/Documents/app-builder/main.go:90 runtime.main /usr/local/Cellar/go/1.17/libexec/src/runtime/proc.go:255 runtime.goexit /usr/local/Cellar/go/1.17/libexec/src/runtime/asm_386.s:1319 • Above command failed, retrying 3 more times ⨯ Get "https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z": dial tcp 20.205.243.166:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. github.com/develar/app-builder/pkg/download.(*Downloader).follow.func1 /Volumes/data/Documents/app-builder/pkg/download/downloader.go:206 github.com/develar/app-builder/pkg/download.(*Downloader).follow /Volumes/data/Documents/app-builder/pkg/download/downloader.go:234 github.com/develar/app-builder/pkg/download.(*Downloader).DownloadNoRetry /Volumes/data/Documents/app-builder/pkg/download/downloader.go:128 github.com/develar/app-builder/pkg/download.(*Downloader).Download /Volumes/data/Documents/app-builder/pkg/download/downloader.go:112 github.com/develar/app-builder/pkg/download.DownloadArtifact /Volumes/data/Documents/app-builder/pkg/download/artifactDownloader.go:107 github.com/develar/app-builder/pkg/download.downloadFromGithub /Volumes/data/Documents/app-builder/pkg/download/tool.go:63 github.com/develar/app-builder/pkg/download.DownloadWinCodeSign /Volumes/data/Documents/app-builder/pkg/download/tool.go:58 github.com/develar/app-builder/pkg/rcedit.editResources /Volumes/data/Documents/app-builder/pkg/rcedit/rcedit.go:30 github.com/develar/app-builder/pkg/rcedit.ConfigureCommand.func1 /Volumes/data/Documents/app-builder/pkg/rcedit/rcedit.go:25 github.com/alecthomas/kingpin.(*actionMixin).applyActions /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/actions.go:28 github.com/alecthomas/kingpin.(*Application).applyActions /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:557 github.com/alecthomas/kingpin.(*Application).execute /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:390 github.com/alecthomas/kingpin.(*Application).Parse /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:222 main.main /Volumes/data/Documents/app-builder/main.go:90 runtime.main /usr/local/Cellar/go/1.17/libexec/src/runtime/proc.go:255 runtime.goexit /usr/local/Cellar/go/1.17/libexec/src/runtime/asm_386.s:1319 • Above command failed, retrying 2 more times ⨯ Get "https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z": dial tcp 20.205.243.166:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. github.com/develar/app-builder/pkg/download.(*Downloader).follow.func1 /Volumes/data/Documents/app-builder/pkg/download/downloader.go:206 github.com/develar/app-builder/pkg/download.(*Downloader).follow /Volumes/data/Documents/app-builder/pkg/download/downloader.go:234 github.com/develar/app-builder/pkg/download.(*Downloader).DownloadNoRetry /Volumes/data/Documents/app-builder/pkg/download/downloader.go:128 github.com/develar/app-builder/pkg/download.(*Downloader).Download /Volumes/data/Documents/app-builder/pkg/download/downloader.go:112 github.com/develar/app-builder/pkg/download.DownloadArtifact /Volumes/data/Documents/app-builder/pkg/download/artifactDownloader.go:107 github.com/develar/app-builder/pkg/download.downloadFromGithub /Volumes/data/Documents/app-builder/pkg/download/tool.go:63 github.com/develar/app-builder/pkg/download.DownloadWinCodeSign /Volumes/data/Documents/app-builder/pkg/download/tool.go:58 github.com/develar/app-builder/pkg/rcedit.editResources /Volumes/data/Documents/app-builder/pkg/rcedit/rcedit.go:30 github.com/develar/app-builder/pkg/rcedit.ConfigureCommand.func1 /Volumes/data/Documents/app-builder/pkg/rcedit/rcedit.go:25 github.com/alecthomas/kingpin.(*actionMixin).applyActions /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/actions.go:28 github.com/alecthomas/kingpin.(*Application).applyActions /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:557 github.com/alecthomas/kingpin.(*Application).execute /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:390 github.com/alecthomas/kingpin.(*Application).Parse /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:222 main.main /Volumes/data/Documents/app-builder/main.go:90 runtime.main /usr/local/Cellar/go/1.17/libexec/src/runtime/proc.go:255 runtime.goexit /usr/local/Cellar/go/1.17/libexec/src/runtime/asm_386.s:1319 • Above command failed, retrying 1 more times ⨯ Get "https://github.com/electron-userland/electron-builder-binaries/releases/download/winCodeSign-2.6.0/winCodeSign-2.6.0.7z": dial tcp 20.205.243.166:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. github.com/develar/app-builder/pkg/download.(*Downloader).follow.func1 /Volumes/data/Documents/app-builder/pkg/download/downloader.go:206 github.com/develar/app-builder/pkg/download.(*Downloader).follow /Volumes/data/Documents/app-builder/pkg/download/downloader.go:234 github.com/develar/app-builder/pkg/download.(*Downloader).DownloadNoRetry /Volumes/data/Documents/app-builder/pkg/download/downloader.go:128 github.com/develar/app-builder/pkg/download.(*Downloader).Download /Volumes/data/Documents/app-builder/pkg/download/downloader.go:112 github.com/develar/app-builder/pkg/download.DownloadArtifact /Volumes/data/Documents/app-builder/pkg/download/artifactDownloader.go:107 github.com/develar/app-builder/pkg/download.downloadFromGithub /Volumes/data/Documents/app-builder/pkg/download/tool.go:63 github.com/develar/app-builder/pkg/download.DownloadWinCodeSign /Volumes/data/Documents/app-builder/pkg/download/tool.go:58 github.com/develar/app-builder/pkg/rcedit.editResources /Volumes/data/Documents/app-builder/pkg/rcedit/rcedit.go:30 github.com/develar/app-builder/pkg/rcedit.ConfigureCommand.func1 /Volumes/data/Documents/app-builder/pkg/rcedit/rcedit.go:25 github.com/alecthomas/kingpin.(*actionMixin).applyActions /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/actions.go:28 github.com/alecthomas/kingpin.(*Application).applyActions /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:557 github.com/alecthomas/kingpin.(*Application).execute /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:390 github.com/alecthomas/kingpin.(*Application).Parse /Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:222 main.main /Volumes/data/Documents/app-builder/main.go:90 runtime.main /usr/local/Cellar/go/1.17/libexec/src/runtime/proc.go:255 runtime.goexit /usr/local/Cellar/go/1.17/libexec/src/runtime/asm_386.s:1319 • Above command failed, retrying 0 more times ⨯ E:\安装包\243243323906\node_modules\.pnpm\app-builder-bin@4.0.0\node_modules\app-builder-bin\win\ia32\app-builder.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE Exit code: 1 failedTask=build stackTrace=Error: E:\安装包\243243323906\node_modules\.pnpm\app-builder-bin@4.0.0\node_modules\app-builder-bin\win\ia32\app-builder.exe process failed ERR_ELECTRON_BUILDER_CANNOT_EXECUTE Exit code: 1 at ChildProcess.<anonymous> (E:\安装包\243243323906\node_modules\.pnpm\builder-util@24.13.1\node_modules\builder-util\src\util.ts:252:14) at Object.onceWrapper (node:events:634:26) at ChildProcess.emit (node:events:519:28) at ChildProcess.cp.emit (E:\安装包\243243323906\node_modules\.pnpm\cross-spawn@7.0.6\node_modules\cross-spawn\lib\enoent.js:34:29) at maybeClose (node:internal/child_process:1105:16) at Process.ChildProcess._handle.onexit (node:internal/child_process:305:5) From previous event: at processImmediate (node:internal/timers:478:21) From previous event: at WinPackager.signApp (E:\安装包\243243323906\node_modules\.pnpm\app-builder-lib@24.13.3_dmg-builder@24.13.3_electron-builder-squirrel-windows@24.13.3\node_modules\app-builder-lib\src\winPackager.ts:384:27) at WinPackager.doSignAfterPack (E:\安装包\243243323906\node_modules\.pnpm\app-builder-lib@24.13.3_dmg-builder@24.13.3_electron-builder-squirrel-windows@24.13.3\node_modules\app-builder-lib\src\platformPackager.ts:336:32) at WinPackager.doPack (E:\安装包\243243323906\node_modules\.pnpm\app-builder-lib@24.13.3_dmg-builder@24.13.3_electron-builder-squirrel-windows@24.13.3\node_modules\app-builder-lib\src\platformPackager.ts:321:7) at WinPackager.pack (E:\安装包\243243323906\node_modules\.pnpm\app-builder-lib@24.13.3_dmg-builder@24.13.3_electron-builder-squirrel-windows@24.13.3\node_modules\app-builder-lib\src\platformPackager.ts:140:5) at Packager.doBuild (E:\安装包\243243323906\node_modules\.pnpm\app-builder-lib@24.13.3_dmg-builder@24.13.3_electron-builder-squirrel-windows@24.13.3\node_modules\app-builder-lib\src\packager.ts:445:9) at executeFinally (E:\安装包\243243323906\node_modules\.pnpm\builder-util@24.13.1\node_modules\builder-util\src\promise.ts:12:14) at Packager._build (E:\安装包\243243323906\node_modules\.pnpm\app-builder-lib@24.13.3_dmg-builder@24.13.3_electron-builder-squirrel-windows@24.13.3\node_modules\app-builder-lib\src\packager.ts:379:31) at Packager.build (E:\安装包\243243323906\node_modules\.pnpm\app-builder-lib@24.13.3_dmg-builder@24.13.3_electron-builder-squirrel-windows@24.13.3\node_modules\app-builder-lib\src\packager.ts:340:12) at executeFinally (E:\安装包\243243323906\node_modules\.pnpm\builder-util@24.13.1\node_modules\builder-util\src\promise.ts:12:14)  ELIFECYCLE  Command failed with exit code 1.
08-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

luffy5459

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值