繁体   English   中英

Python脚本单独工作,但通过nodejs子进程运行时没有这样的文件

[英]Python script works alone but no such file when run through nodejs child process

Error, could not create TXT output file: No such file or directory

tesseract ./downloads/en.jpg outputs/1585336201.287781output -l eng

是我遇到的错误,这个命令在 python 脚本中工作正常,但不能通过 childprocess spawn,下载和 .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权限

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM