question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
PauloKoglincommented, Apr 29, 2020

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.

0reactions
ToWelie89commented, Jul 23, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

If/Else in shell script throws errors in Ubuntu for Windows
There are two problems here. First, while you have a shebang line calling bash, you are executing the script as sh script.sh ....
Read more >
Failure in executing shell script producing output on Ubuntu ...
You appear to have mangled text in nonexistentssion.sh: and No such file or directorytput.txt which suggests you might have Windows line-endings ...
Read more >
Troubleshooting Windows Subsystem for Linux | Microsoft Learn
Provides detailed information about common errors and issues people run into while running Linux on the Windows Subsystem for Linux.
Read more >
Unable to run shell script in windows 10 with Bash on Ubuntu
1 Answer 1 · This script is compiled in such a way that matters where it is running. · Another possible problem -...
Read more >
Ubuntu Server Documentation
The Ubuntu Server Edition and the Ubuntu Desktop Edition use the same apt ... When running on serial, the installer starts in a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found