python - Python脚本单独工作,但通过nodejs子进程运行时没有这样的文件
问题描述
Error, could not create TXT output file: No such file or directory
tesseract ./downloads/en.jpg outputs/1585336201.287781output -l eng
是我遇到问题的错误,此命令在 python 脚本中运行良好,但不能通过子进程生成,下载和 .py 脚本位于同一文件夹中,并且它们都位于 nodejs 脚本旁边的文件夹中
这是我从 post 函数调用的方法,给它我需要转录的想象,然后 python 脚本无法运行 tesseract 命令,即使它可以在手动运行时执行
const verif = async (fileName, filePath) => {
var uint8arrayToString = function(data){
return String.fromCharCode.apply(null, data);
};
const spawn = require('child_process').spawn;
const scriptExecution = spawn('python',['-u', './diploma/app.py']);
var data = JSON.stringify([fileName]);
scriptExecution.stdin.write(data);
scriptExecution.stdin.end();
scriptExecution.stdout.on('data', (data) => {
console.log(uint8arrayToString(data));
});
scriptExecution.stderr.on('data', (data) => {
// As said before, convert the Uint8Array to a readable string.
console.log(uint8arrayToString(data));
});
scriptExecution.on('exit', (code) => {
console.log("Process quit with code : " + code);
});
return true;
}
解决方案
问题是tesseract从js文件执行时需要windows权限
推荐阅读
- php - 多维数组展平技术仍然会留下空数组
- mysql - 具有 3000 万条记录的搜索表
- javascript - 无法在 Function.keys 将 undefined 或 null 转换为对象
- symfony - symfony 5 mercure bundle HTTP/1.1 400 Bad Request 返回
- angular - ngx-bootstrap嵌套手风琴在动画时不更新高度
- python - 从填充了多种数据类型的字符串中分离数据
- javascript - 正则表达式 - 仅匹配子字符串后的两位数字
- drupal - DDEV和D8,用于内部请求的httpClient连接失败
- javascript - Java 脚本日期函数
- javascript - 我可以将数组存储在 html 元素中,然后再次将其用作数组吗