使用 python 的 Electron 应用程序抛出 zmq.node 错误

Electron app using python throws zmq.node error

完全公开我是一个 node/npm/electron 菜鸟,但我正在尝试构建一个 electron 应用程序来与我编写的现有 python 模块交互,我遇到了 this Github repo。所以我克隆了它,并尝试从 linux mint cinnamon 版本 3.2.7 中 运行 它。电子应用程序启动,但 python 组件不起作用。当我打开开发人员工具时,控制台显示此错误消息;

Uncaught Error: Cannot find module '../build/Release/zmq.node'
    at Module._resolveFilename (module.js:470:15)
    at Function.Module._resolveFilename (/home/jad/Github/electron-python-example/node_modules/electron/dist/resources/electron.asar/common/reset-search-paths.js:35:12)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/jad/Github/electron-python-example/node_modules/zeromq/lib/index.js:6:11)
    at Object.<anonymous> (/home/jad/Github/electron-python-example/node_modules/zeromq/lib/index.js:839:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)

事实证明其他人也有这个问题并且引用了 solution was posted where 但是当我 运行 以下内容时;

npm install --save-dev electron-rebuild
./node_modules/.bin/electron-rebuild

我收到以下错误消息;

An unhandled error occurred inside electron-rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.1
gyp info using node@7.10.0 | linux | x64
gyp http GET https://atom.io/download/electron/v1.6.8/iojs-v1.6.8.tar.gz
gyp http 200 https://atom.io/download/electron/v1.6.8/iojs-v1.6.8.tar.gz
gyp http GET https://atom.io/download/electron/v1.6.8/SHASUMS256.txt
gyp http 200 https://atom.io/download/electron/v1.6.8/SHASUMS256.txt
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/home/jad/Github/electron-python-example/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/jad/Github/electron-python-example/node_modules/zeromq/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/jad/Github/electron-python-example/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/jad/.electron-gyp/.node-gyp/iojs-1.6.8/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/jad/.electron-gyp/.node-gyp/iojs-1.6.8',
gyp info spawn args   '-Dnode_gyp_dir=/home/jad/Github/electron-python-example/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=iojs.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/jad/Github/electron-python-example/node_modules/zeromq',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/jad/Github/electron-python-example/node_modules/zeromq/build'
  CXX(target) Release/obj.target/zmq/binding.o
  SOLINK_MODULE(target) Release/obj.target/zmq.node
g++: error: ./Release/../../zmq/lib/libzmq.a: No such file or directory
zmq.target.mk:123: recipe for target 'Release/obj.target/zmq.node' failed
make: Leaving directory '/home/jad/Github/electron-python-example/node_modules/zeromq/build'
make: *** [Release/obj.target/zmq.node] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/jad/Github/electron-python-example/node_modules/node-gyp/lib/build.js:285:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:194:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-78-generic
gyp ERR! command "/usr/local/bin/node" "/home/jad/Github/electron-python-example/node_modules/.bin/node-gyp" "rebuild" "--target=1.6.8" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source"
gyp ERR! cwd /home/jad/Github/electron-python-example/node_modules/zeromq
gyp ERR! node -v v7.10.0
gyp ERR! node-gyp -v v3.6.1
gyp ERR! not ok 

Failed with exit code: 1

Error: gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.1
gyp info using node@7.10.0 | linux | x64
gyp http GET https://atom.io/download/electron/v1.6.8/iojs-v1.6.8.tar.gz
gyp http 200 https://atom.io/download/electron/v1.6.8/iojs-v1.6.8.tar.gz
gyp http GET https://atom.io/download/electron/v1.6.8/SHASUMS256.txt
gyp http 200 https://atom.io/download/electron/v1.6.8/SHASUMS256.txt
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/home/jad/Github/electron-python-example/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/jad/Github/electron-python-example/node_modules/zeromq/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/jad/Github/electron-python-example/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/jad/.electron-gyp/.node-gyp/iojs-1.6.8/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/jad/.electron-gyp/.node-gyp/iojs-1.6.8',
gyp info spawn args   '-Dnode_gyp_dir=/home/jad/Github/electron-python-example/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=iojs.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/jad/Github/electron-python-example/node_modules/zeromq',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/jad/Github/electron-python-example/node_modules/zeromq/build'
  CXX(target) Release/obj.target/zmq/binding.o
  SOLINK_MODULE(target) Release/obj.target/zmq.node
g++: error: ./Release/../../zmq/lib/libzmq.a: No such file or directory
zmq.target.mk:123: recipe for target 'Release/obj.target/zmq.node' failed
make: Leaving directory '/home/jad/Github/electron-python-example/node_modules/zeromq/build'
make: *** [Release/obj.target/zmq.node] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/jad/Github/electron-python-example/node_modules/node-gyp/lib/build.js:285:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:194:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-78-generic
gyp ERR! command "/usr/local/bin/node" "/home/jad/Github/electron-python-example/node_modules/.bin/node-gyp" "rebuild" "--target=1.6.8" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source"
gyp ERR! cwd /home/jad/Github/electron-python-example/node_modules/zeromq
gyp ERR! node -v v7.10.0
gyp ERR! node-gyp -v v3.6.1
gyp ERR! not ok 

Failed with exit code: 1
    at SafeSubscriber._error (/home/jad/Github/electron-python-example/node_modules/spawn-rx/lib/src/index.js:262:84)
    at SafeSubscriber.__tryOrUnsub (/home/jad/Github/electron-python-example/node_modules/rxjs/Subscriber.js:238:16)
    at SafeSubscriber.error (/home/jad/Github/electron-python-example/node_modules/rxjs/Subscriber.js:197:26)
    at Subscriber._error (/home/jad/Github/electron-python-example/node_modules/rxjs/Subscriber.js:128:26)
    at Subscriber.error (/home/jad/Github/electron-python-example/node_modules/rxjs/Subscriber.js:102:18)
    at MapSubscriber.Subscriber._error (/home/jad/Github/electron-python-example/node_modules/rxjs/Subscriber.js:128:26)
    at MapSubscriber.Subscriber.error (/home/jad/Github/electron-python-example/node_modules/rxjs/Subscriber.js:102:18)
    at SafeSubscriber._next (/home/jad/Github/electron-python-example/node_modules/spawn-rx/lib/src/index.js:236:65)
    at SafeSubscriber.__tryOrSetError (/home/jad/Github/electron-python-example/node_modules/rxjs/Subscriber.js:247:16)
    at SafeSubscriber.next (/home/jad/Github/electron-python-example/node_modules/rxjs/Subscriber.js:187:27)

有什么方法可以解决 fix/get-around 这个问题?

我有同样的问题,我的解决方案是在 运行 npm start

之前使用这个 npm rebuild zeromq --runtime=electron --target=1.6.2(你的版本)

所有信息here