0
votes

I am using ruby on rails to run some OCR tasks. I am attempting to use the tesseract-ocr gem (https://github.com/meh/ruby-tesseract-ocr).

In my Gemfile, if the tesseract-ocr gem is listed as below:
gem 'tesseract-ocr'

I get the following error:

C:\Users\Redacted\Desktop\Rails\cx-master>rails c The system cannot find the path specified. C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:85:in rescue in block (2 levels) in require': There was an error while trying to load the gem 'tesseract-ocr'. (Bundler::GemRequireError) Gem Load Error is: compile error: see logs at C:/Users/Redacted_~1/AppData/Local/Temp/.ffi-inline-0/6a21dd7f0d1fcf6ba9de29522e4ac8d7604046d7.log Backtrace for gem load error is: C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ffi-inline-0.0.4.3/lib/ffi/inline/compilers/gcc.rb:35:incompile' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders/c.rb:114:in shared_object' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:90:inblock in build' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:87:in instance_eval' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:87:inbuild' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ffi-inline-0.0.4.3/lib/ffi/inline/inline.rb:54:in singleton_inline' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ffi-inline-0.0.4.3/lib/ffi/inline/inline.rb:39:ininline' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/tesseract-ocr-0.1.8/lib/tesseract/c.rb:34:in <module:C>' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/tesseract-ocr-0.1.8/lib/tesseract/c.rb:31:in' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/tesseract-ocr-0.1.8/lib/tesseract/c.rb:29:in <top (required)>' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/tesseract-ocr-0.1.8/lib/tesseract/api.rb:26:inrequire' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/tesseract-ocr-0.1.8/lib/tesseract/api.rb:26:in <top (required)>' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/tesseract-ocr-0.1.8/lib/tesseract-ocr.rb:35:inrequire' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/tesseract-ocr-0.1.8/lib/tesseract-ocr.rb:35:in <top (required)>' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:82:inrequire' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:82:in block (2 levels) in require' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:77:ineach' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:77:in block in require' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:66:ineach' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:66:in require' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler.rb:108:inrequire' C:/Users/Redacted/Desktop/Rails/cx-master/config/application.rb:7:in <top (required)>' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/actions.rb:15:inrequire' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/actions.rb:15:in require_application_and_environment!' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands/console/console_command.rb:96:inperform' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in run' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:ininvoke_command' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in dispatch' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:inperform' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in invoke' C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in' bin/rails:4:in require' bin/rails:4:in' Bundler Error Backtrace: from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:81:in block (2 levels) in require' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:77:ineach' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:77:in block in require' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:66:ineach' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler/runtime.rb:66:in require' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.15.3/lib/bundler.rb:108:inrequire' from C:/Users/Redacted/Desktop/Rails/cx-master/config/application.rb:7:in <top (required)>' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/actions.rb:15:inrequire' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/actions.rb:15:in require_application_and_environment!' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands/console/console_command.rb:96:inperform' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in run' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:ininvoke_command' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in dispatch' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:inperform' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in invoke' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in' from bin/rails:4:in require' from bin/rails:4:in'

(if I remove the gem, however, the app works just fine)

Tesseract is installed:
C:\Users\Redacted\Desktop\Rails\cx-master>tesseract -v tesseract 3.05.01 leptonica-1.74.1 libgif 4.1.6(?) : libjpeg 8d (libjpeg-turbo 1.5.0) : libpng 1.6.20 : libtiff 4.0.6 : zlib 1.2.8 : libwebp 0.4.3 : libopenjp2 2.1.0

and so is the gem:
C:\Users\Redacted\Desktop\Rails\cx-master>gem list tesseract-ocr *** LOCAL GEMS *** tesseract-ocr (0.1.8)

PATHS are also set:
Path=C:\Program Files (x86)\Tesseract-OCR
TESSDATA_PREFIX=C:\Program Files (x86)\Tesseract-OCR

So the crux of the problem is: while the tesseract-ocr gem is listed in the Gemfile, I cannot run the app. I'm on day 3 of going round in circles with this error, so a fresh pair of eyes & any help is much appreciated.

1
Let me know the below solution work or notAniket Shivam Tiwari
Still searching for a solution hereHarkell
Still searchingHarkell
please share your rails,ruby version also uninstall the gem. And try reinstalling itAniket Shivam Tiwari

1 Answers

0
votes

For Windows you can install from this link

First install these

 sudo apt-get install libtesseract-dev

And

sudo apt-get install libleptonica-dev

Then run this on your terminal

gem install 'tesseract-ocr'

Please install by this link. This gem 'tesseract-ocr' has been old and no support is provided.Try for the link which I have provided