添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I have an electron project which uses a python 3 environment for a segment of the app and thus the entirety of my repo’s environment is python 3.

When I run build -m --x64 to build for Mac (or the equivalent for windows) I get an error that node-gyp can’t find python2. I know that node-gyp is not compatible with python3… I normally have npm set to use python 2 for node-gyp with: npm config set python /usr/bin/python2.7

And anytime I use npm within a python 3 environment I don’t get an error about node-gpy not finding python2.

Also, within my project which has python 3.4.3 I can run electron-packager and create windows/mac builds without any errors from node-gyp being unable to find python 2.

But when I run electron-builder it seems that my environment has to be set to python 2. Two question I have are,

  • How can I tell electron-builder the path to python 2 when it invokes node-gyp/electron-packager (if I understand how things work internally and I may not)…
  • How is that electron-packager can package the same app in a python 3 environment but electron-builder needs the environments python to be strictly python 2 to work…
  • Right now I build a segment of my application using python 3 then switch to python 2 to build the rest since I’ve switched from electron-packager to electron-builder…

    I can write scripts locally and on our CI (travis, appveyor) that do this python version switching but I’m hoping that won’t be unnecessary. For now I’ll have to do that to finish my work…

    Below is the node-gyp error I get because my environment is in python 3,

    $ build -m --x64                            
    Rebuilding app dependencies for arch x64 to /Users/moi/Code/foo/otone_frontend/app
    gyp ERR! configure error
    gyp ERR! stack Error: Command failed: /opt/boxen/pyenv/shims/python2 -c import platform; print(platform.python_version());
    gyp ERR! stack pyenv: python2: command not found
    gyp ERR! stack
    gyp ERR! stack The `python2' command exists in these Python versions:
    gyp ERR! stack   2.7.5
    gyp ERR! stack   2.7.7
    gyp ERR! stack   2.7.9
    gyp ERR! stack
    gyp ERR! stack
    gyp ERR! stack     at ChildProcess.exithandler (child_process.js:202:12)
    gyp ERR! stack     at emitTwo (events.js:106:13)
    gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
    gyp ERR! stack     at maybeClose (internal/child_process.js:850:16)
    gyp ERR! stack     at Socket.<anonymous> (internal/child_process.js:323:11)
    gyp ERR! stack     at emitOne (events.js:96:13)
    gyp ERR! stack     at Socket.emit (events.js:188:7)
    gyp ERR! stack     at Pipe._handle.close [as _onclose] (net.js:485:12)
    gyp ERR! System Darwin 13.4.0
    gyp ERR! command "/opt/boxen/nodenv/versions/v6.0.0/bin/node" "/opt/boxen/nodenv/versions/v6.0.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /Users/moi/Code/foo/otone_frontend/app/node_modules/bufferutil
    gyp ERR! node -v v6.0.0
    gyp ERR! node-gyp -v v3.3.1
    gyp ERR! not ok
    npm ERR! Darwin 13.4.0
    npm ERR! argv "/opt/boxen/nodenv/versions/v6.0.0/bin/node" "/opt/boxen/nodenv/versions/v6.0.0/bin/npm" "rebuild" "--production"
    npm ERR! node v6.0.0
    npm ERR! npm  v3.8.6
    npm ERR! code ELIFECYCLE
    npm ERR! [email protected] install: `node-gyp rebuild`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
    npm ERR! Make sure you have the latest version of node.js and npm installed.
    npm ERR! If you do, this is most likely a problem with the bufferutil package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR!     node-gyp rebuild
    npm ERR! You can get information on how to open an issue for this project with:
    npm ERR!     npm bugs bufferutil
    npm ERR! Or if that isn't available, you can get their info via:
    npm ERR!     npm owner ls bufferutil
    npm ERR! There is likely additional logging output above.
    npm ERR! Please include the following file with any support request:
    npm ERR!     /Users/moi/Code/foo/otone_frontend/app/npm-debug.log
    Error: npm exited with code 1
        at ChildProcess.childProcess.on.code (/Users/moi/Code/foo/otone_frontend/node_modules/electron-builder/src/util/util.ts:132:14)
        at emitTwo (events.js:106:13)
        at ChildProcess.emit (events.js:191:7)
        at maybeClose (internal/child_process.js:850:16)
        at Socket.<anonymous> (internal/child_process.js:323:11)
        at emitOne (events.js:96:13)
        at Socket.emit (events.js:188:7)
        at Pipe._handle.close [as _onclose] (net.js:485:12)
    From previous event:
        at spawn (/Users/moi/Code/foo/otone_frontend/node_modules/electron-builder/src/util/util.ts:109:9)
        at spawnNpmProduction (/Users/moi/Code/foo/otone_frontend/node_modules/electron-builder/src/util/util.ts:43:9)
        at Object.installDependencies (/Users/moi/Code/foo/otone_frontend/node_modules/electron-builder/src/util/util.ts:21:120)
        at Packager.<anonymous> (/Users/moi/Code/foo/otone_frontend/node_modules/electron-builder/src/packager.ts:214:34)
        at next (native)
        at tryOnImmediate (timers.js:543:15)
        at processImmediate [as _immediateCallback] (timers.js:523:5)
    From previous event:
        at tsAwaiter (/Users/moi/Code/foo/otone_frontend/node_modules/electron-builder/src/util/awaiter.ts:10:47)
        at Object.build (/Users/moi/Code/foo/otone_frontend/node_modules/electron-builder/src/builder.ts:195:52)
        at Object.<anonymous> (/Users/moi/Code/foo/otone_frontend/node_modules/electron-builder/src/build-cli.ts:27:28)
        at Module._compile (module.js:541:32)
        at Object.Module._extensions..js (module.js:550:10)
        at Module.load (module.js:456:32)
        at tryModuleLoad (module.js:415:12)
        at Function.Module._load (module.js:407:3)
        at Function.Module.runMain (module.js:575:10)
        at startup (node.js:159:18)
        at node.js:444:3
    

    Issue Analytics

    • State:closed
    • Created 7 years ago
    • Comments:9 (2 by maintainers)

    github_iconTop GitHub Comments

    36reactions
    Mazyodcommented, Oct 9, 2017

    I could’ve sworn this didn’t work for me the first time, but running this solved the issue:

    pyenv shell "2.7.10"
    

    error I was getting:

    gyp ERR! configure error 
    gyp ERR! stack Error: Command failed: /Users/.../.pyenv/shims/python2 -c import platform; print(platform.python_version());
    gyp ERR! stack pyenv: python2: command not found
    gyp ERR! stack 
    gyp ERR! stack The `python2' command exists in these Python versions:
    gyp ERR! stack   2.7.10
    
    14reactions
    develarcommented, Aug 4, 2016

    I can run electron-packager and create windows/mac builds without any errors from node-gyp being unable to find python 2.