2

I was having problems with Ubuntu 22.04 on my Framework laptop, and did a complete re-installation, using Ubuntu 24.04.1. I have just reinstalled Tesseract using snap. It was was working ok previously on Ubuntu 22.04, but now gives the error:

Error opening data file /snap/tesseract/current/usr/local/share/tessdata/eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
Could not initialize tesseract.

I tried to install English as follows:

sudo apt-get install tesseract-ocr-eng

which was apparently successful, but using:

tesseract --list-langs

I got the following response:

List of available languages in "/snap/tesseract/current/usr/local/share/tessdata/" (0):

and trying to translate something gave the same error as above.

I have tried searching for this problem without success. Any ideas?

Many thanks, Andrew

  • Why are you installing the snap version of tesseract while the language package is installed through apt? – FedKad Dec 27 '24 at 13:23
  • because I don't understand snap and apt! I didn't realise they were both oranges: I thought apt was a command and snap was a place to get software, i.e. oranges and apples... ...I would be grateful for full clarification of my confusion! – Andrew Corser Dec 28 '24 at 15:58

1 Answers1

1

If I were you, I would just install the apt version of tesseract and not the snap version:

$ sudo snap remove tesseract
$ sudo apt install tesseract-ocr tesseract-ocr-eng

After the above commands, you should have the following:

$ type tesseract
tesseract is /usr/bin/tesseract

If not, you may have to log out and then log back in and / or check your $PATH environment variable.

Also, the command

$ snap list | grep -i tesseract

should give you no output.

FedKad
  • 13,900
  • Thanks! I have done this, and the result is:

    framework:~/Downloads$ tesseract bash: /snap/bin/tesseract: No such file or directory

    – Andrew Corser Dec 28 '24 at 16:01
  • You may have to re-login. And, what is the output of apt --installed list "tesseract*"? – FedKad Dec 28 '24 at 19:30
  • Did this first: framework:~$ apt --installed list "tesseract*" Listing... Done tesseract-ocr-eng/noble,noble,now 1:4.1.0-2 all [installed] tesseract-ocr-osd/noble,noble,now 1:4.1.0-2 all [installed,automatic] tesseract-ocr-ukr/noble,noble,now 1:4.1.0-2 all [installed] tesseract-ocr/noble,now 5.3.4-1build5 amd64 [installed]

    will re-login now

    – Andrew Corser Dec 29 '24 at 21:04
  • 1
    Aha! Just restarted and it worked! Thank you FedKad!

    By the bye, is there ever any point in using snap?

    – Andrew Corser Dec 29 '24 at 21:10
  • 1
    Besides snaps being much more up-to-date (like in Firefox and Thunderbird) than apt packages, I don't see any practical point. – FedKad Dec 30 '24 at 06:10
  • @AndrewCorser Accepting and / or upvoting an answer that helped you is an expected action to help other people with similar problem / questions. – FedKad Dec 30 '24 at 12:32
  • 1
    You may not need to log out and back in to get bash to find the new path of the executable. hash -r worked for me. See After installing binary to another directory, error "No such file or directory". See also 'hash' under SHELL BUILTIN COMMANDS in man bash. – AlanQ Apr 18 '25 at 00:04
  • Pity, tesseract 4 from apt fails royally on a simple image with numbers. So having a chance to try 5 would be a thing. – Harald Jul 25 '25 at 16:01