zapolnoch/node-tesseract-ocr

Running in Windows gives error but running in Ubuntu with same script is fine

doverradio opened this issue · 5 comments

Hello,

Here is the working script which works on Linux.

const tesseract = require('node-tesseract-ocr');

const config = {
  lang: 'eng',
  oem: 1,
  psm: 3
}
 
tesseract
  .recognize('image.jpg', config)
  .then(text => {
    console.log('Result:', text)
  })
  .catch(err => {
    console.log('error:', err)
  })

Here is the non-working script I used on Windows (same package.json).

const tesseract = require('node-tesseract-ocr');

const config = {
  lang: 'eng',
  oem: 1,
  psm: 3
}
 
tesseract
  .recognize('image.jpg', config)
  .then(text => {
    console.log('Result:', text)
  })
  .catch(err => {
    console.log('error:', err)
  })

Identical.

Here is the error message:

error: { Error: Command failed: tesseract image.jpg stdout -l eng --oem 1 --psm 3
'tesseract' is not recognized as an internal or external command,
operable program or batch file.

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
  killed: false,
  code: 1,
  signal: null,
  cmd: 'tesseract image.jpg stdout -l eng --oem 1 --psm 3' }

What is going on? How can I solve this error?

Hi.
Please, open the console (cmd.exe) and write:

tesseract --version

If you catch an error, check that Tesseract is installed and System Variable PATH is correctly set.

Any solution to this problem? I have tesseract install well but when I try running using node-tesseract-ocr I get this error. However, when I directly run tesseract <path-to-image> stdout -l eng --oem 1 --psm 3 It works so well like so:

`tesseract ./test.jpg stdout -l eng --oem 1 --psm 3
Computers pro :
cess d. : :
set ata. Quite often the data are organized in some

a y manner—a Statistical time series, for example, or the output of

experiment that varies as the input is varied, or a list of names in
alphabetic order. A collection of data whose elements form an ordered
sequence is called an array. The elements of an array can be of any
data type (as long as they are all the same type), so we can have an
array of ints, an array of doubles, an array of chars, etc—even an array

of arrays, since, in fact, the array is one of C’s secondary data types,
that is, it can be derived from a primary data type.

In this chapter, we shall discuss the characteristics of C arrays and
the notation in which they are described. In the next chapter we shall
discuss how the elements of an array can be manipulated through the

use of pointers.

s-rav Definitions`

What might be the problem with the package?

Hi @doverradio , I had the same problem. I assume you're using VS-Code to code and to run it (with the VS-Code Terminal). In these case, the problem is something with the Powershell, that doesn't recognize the command "tesseract".

To solve this problem, try to run your application using CMD. It works fine for me.

'tesseract' is not recognized as an internal or external command,
operable program or batch file.

I am having this issue, can anyone help me with this?

Hi @doverradio , I had the same problem. I assume you're using VS-Code to code and to run it (with the VS-Code Terminal). In these case, the problem is something with the Powershell, that doesn't recognize the command "tesseract".

To solve this problem, try to run your application using CMD. It works fine for me.

Didn't solve it for me. I tried installing the pacakge globally as well but that didn't help