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

时间:2017-05-22 15:24:40

标签: python node.js npm electron gyp

完全披露我是一个节点/ npm /电子菜鸟,但我试图建立一个电子应用程序来与我写的现有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引用了this SO answer,但是当我运行以下内容时

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)

有没有办法解决这个问题?

1 个答案:

答案 0 :(得分:4)

我遇到同样的问题,我的解决方案是在运行npm rebuild zeromq --runtime=electron --target=1.6.2

之前使用此npm start(您的版本)

所有信息here