Ruby on Rails tesseract-ocr gem path错误

时间:2017-10-23 13:49:09

标签: ruby-on-rails windows rubygems ruby-on-rails-5 tesseract

我在rails上使用ruby来运行一些OCR任务。我试图使用tesseract-ocr gem(https://github.com/meh/ruby-tesseract-ocr)。

在我的Gemfile中,如果tesseract-ocr gem列出如下:
gem 'tesseract-ocr'

我收到以下错误:

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'

(如果我删除了宝石,那么应用就可以了。)

安装了Tesseract:
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: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: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: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:in

问题的症结在于:虽然gesfile中列出了tesseract-ocr gem,但我无法运行该应用程序。我在第3天绕着这个错误绕圈而来,所以一双新鲜的眼睛&amp;非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

对于Windows,您可以从此link

进行安装

首先安装这些

 sudo apt-get install libtesseract-dev

sudo apt-get install libleptonica-dev

然后在您的终端上运行

gem install 'tesseract-ocr'

请按此link安装。这个 gem'tesseract-ocr'已经过时了,没有提供任何支持。请尝试我提供的链接