【发布时间】:2015-02-21 07:38:32
【问题描述】:
我正在尝试从 CasperJS 中调用 python 脚本并从 python 中获取输出。
casp = require('casper').create({
verbose: true,
logLevel: 'debug'
});
casp.start().then(function() {
var cp = require('child_process');
cp.execFile('/usr/bin/python','test.py', {},function(_,stdout,stderr){
console.log(stdout);
console.log(stderr);
});
});
casp.run();
test.py 只是 print "hello world" atm 用于测试,但是当我运行这个脚本时它只是退出而不运行 python。
如果我用 --version 替换 test.py 参数,例如
cp.execFile('/usr/bin/python','--version', {},function(_,stdout,stderr){
然后我正确地获取了版本信息。我认为这一定是execFile中如何传递参数的问题,但不确定我应该做什么。
【问题讨论】:
-
你是在 casperjs.cmd 还是其他地方更新了路径?
-
不,没有对 casperjs 进行任何更改,全新下载
标签: javascript python phantomjs casperjs