我怎么知道是否安装了jruby模块?

时间:2014-04-17 17:07:40

标签: ruby pdf jruby tabula

我对Ruby,Rails,Jruby非常不熟悉。但我真的想试试tabula-extractor。我相信我安装得很好,所以我不知道如何检查。这是我的脚本,基于他们的初步建议:

#!/usr/bin/jruby

require 'tabula'

pdf_file_path = "page19.pdf"
outfilename = "page19.csv"

out = open(outfilename, 'w')

extractor = Tabula::Extraction::ObjectExtractor.new(pdf_file_path, :all )
extractor.extract.each do |pdf_page|
  pdf_page.spreadsheets.each do |spreadsheet|
    out << spreadsheet.to_csv
    out << "\n\n"
  end
end
out.close

这是我运行时得到的结果:

./tabula.rb:10: uninitialized constant Tabula (NameError)
    from ./tabula.rb:3:in `require'
    from ./tabula.rb:3

我甚至不确定如何解释这一点。并不是说Tabula无法找到,只是因为有一个&#34; NameError&#34;与extractor = Tabula::Extraction::ObjectExtractor.new(pdf_file_path, :all )

我确定我错过了一些明显的东西。我甚至无法判断是否真的安装了tabula-extractor。我跑了jruby -S gem install tabula-extractor然后回来了:

JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
System.java:-2:in `arraycopy': java.lang.ArrayIndexOutOfBoundsException
    from DefaultResolver.java:111:in `makeTime'
    from DefaultResolver.java:277:in `create'
    from DefaultResolver.java:317:in `handleScalar'
    from DefaultResolver.java:435:in `orgHandler'
    from DefaultResolver.java:455:in `node_import'
    from org/yecht/ruby/DefaultResolver$s_method_1_0$RUBYINVOKER$node_import.gen:65535:in `call'
    from CachingCallSite.java:146:in `call'
    from RubyLoadHandler.java:39:in `handle'
    from Parser.java:300:in `addNode'
    from DefaultYAMLParser.java:676:in `yyparse'
    from Parser.java:290:in `yechtparse'
    from Parser.java:284:in `parse'
    from YParser.java:152:in `load'
    from org/yecht/ruby/YParser$s_method_0_1$RUBYINVOKER$load.gen:65535:in `call'
    from JavaMethod.java:630:in `call'
    from DynamicMethod.java:186:in `call'
    from CachingCallSite.java:309:in `cacheAndCall'
    from CachingCallSite.java:148:in `call'
    from CallOneArgNode.java:57:in `interpret'
    from LocalAsgnNode.java:123:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from InterpretedMethod.java:180:in `call'
    from DefaultMethod.java:174:in `call'
    from CachingCallSite.java:309:in `cacheAndCall'
    from CachingCallSite.java:148:in `call'
    from CallOneArgNode.java:57:in `interpret'
    from LocalAsgnNode.java:123:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedMethod.java:180:in `call'
    from DefaultMethod.java:174:in `call'
    from CachingCallSite.java:309:in `cacheAndCall'
    from CachingCallSite.java:148:in `call'
    from CallOneArgNode.java:57:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from RescueNode.java:199:in `executeBody'
    from RescueNode.java:118:in `interpretWithJavaExceptions'
    from RescueNode.java:110:in `interpret'
    from InterpretedMethod.java:180:in `call'
    from DefaultMethod.java:174:in `call'
    from CachingCallSite.java:309:in `cacheAndCall'
    from CachingCallSite.java:148:in `call'
    from FCallOneArgNode.java:36:in `interpret'
    from InstAsgnNode.java:95:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from EnsureNode.java:96:in `interpret'
    from BeginNode.java:83:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from WhenOneArgNode.java:36:in `whenSlowTest'
    from WhenOneArgNode.java:46:in `when'
    from CaseNode.java:133:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from InterpretedBlock.java:373:in `evalBlockBody'
    from InterpretedBlock.java:346:in `yield'
    from InterpretedBlock.java:303:in `yield'
    from Block.java:194:in `yield'
    from YieldNode.java:112:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedBlock.java:373:in `evalBlockBody'
    from InterpretedBlock.java:346:in `yield'
    from InterpretedBlock.java:303:in `yield'
    from Block.java:194:in `yield'
    from RubyKernel.java:1251:in `loop_1_9'
    from org/jruby/RubyKernel$s_method_0_0$RUBYFRAMEDINVOKER$loop_1_9.gen:65535:in `call'
    from CachingCallSite.java:299:in `cacheAndCall'
    from CachingCallSite.java:117:in `callBlock'
    from CachingCallSite.java:132:in `callIter'
    from FCallNoArgBlockNode.java:32:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from InterpretedMethod.java:160:in `call'
    from DefaultMethod.java:166:in `call'
    from CachingCallSite.java:299:in `cacheAndCall'
    from CachingCallSite.java:117:in `callBlock'
    from CachingCallSite.java:122:in `call'
    from CallNoArgBlockNode.java:64:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedMethod.java:242:in `call'
    from DefaultMethod.java:198:in `call'
    from CachingCallSite.java:339:in `cacheAndCall'
    from CachingCallSite.java:197:in `callBlock'
    from CachingCallSite.java:202:in `call'
    from RubyClass.java:819:in `call'
    from DynamicMethod.java:194:in `call'
    from WrapperMethod.java:62:in `call'
    from CachingCallSite.java:329:in `cacheAndCall'
    from CachingCallSite.java:188:in `call'
    from FCallTwoArgNode.java:38:in `interpret'
    from LocalAsgnNode.java:123:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from EnsureNode.java:96:in `interpret'
    from InterpretedMethod.java:242:in `call'
    from DefaultMethod.java:198:in `call'
    from CachingCallSite.java:339:in `cacheAndCall'
    from CachingCallSite.java:197:in `callBlock'
    from CachingCallSite.java:202:in `call'
    from CallTwoArgBlockPassNode.java:62:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedMethod.java:283:in `call'
    from DefaultMethod.java:214:in `call'
    from CachingCallSite.java:359:in `cacheAndCall'
    from CachingCallSite.java:237:in `callBlock'
    from CachingCallSite.java:252:in `callIter'
    from CallThreeArgBlockNode.java:64:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedMethod.java:262:in `call'
    from DefaultMethod.java:206:in `call'
    from CachingCallSite.java:349:in `cacheAndCall'
    from CachingCallSite.java:228:in `call'
    from FCallThreeArgNode.java:40:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from InterpretedBlock.java:373:in `evalBlockBody'
    from InterpretedBlock.java:346:in `yield'
    from InterpretedBlock.java:303:in `yield'
    from Block.java:194:in `yield'
    from RubyIO.java:1106:in `open'
    from RubyKernel.java:283:in `open'
    from org/jruby/RubyKernel$s_method_0_2$RUBYFRAMEDINVOKER$open.gen:65535:in `call'
    from DynamicMethod.java:198:in `call'
    from CachingCallSite.java:339:in `cacheAndCall'
    from CachingCallSite.java:197:in `callBlock'
    from CachingCallSite.java:212:in `callIter'
    from FCallTwoArgBlockNode.java:34:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from IfNode.java:119:in `interpret'
    from IfNode.java:119:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedMethod.java:221:in `call'
    from DefaultMethod.java:190:in `call'
    from CachingCallSite.java:329:in `cacheAndCall'
    from CachingCallSite.java:188:in `call'
    from CallTwoArgNode.java:59:in `interpret'
    from InstAsgnNode.java:95:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from RescueNode.java:199:in `executeBody'
    from RescueNode.java:118:in `interpretWithJavaExceptions'
    from RescueNode.java:110:in `interpret'
    from BeginNode.java:83:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedMethod.java:242:in `call'
    from DefaultMethod.java:198:in `call'
    from CachingCallSite.java:339:in `cacheAndCall'
    from CachingCallSite.java:197:in `callBlock'
    from CachingCallSite.java:202:in `call'
    from RubyClass.java:819:in `call'
    from DynamicMethod.java:194:in `call'
    from CachingCallSite.java:329:in `cacheAndCall'
    from CachingCallSite.java:188:in `call'
    from CallTwoArgNode.java:59:in `interpret'
    from DAsgnNode.java:110:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedBlock.java:373:in `evalBlockBody'
    from InterpretedBlock.java:346:in `yield'
    from InterpretedBlock.java:303:in `yield'
    from Block.java:194:in `yield'
    from RubyArray.java:1630:in `eachCommon'
    from RubyArray.java:1637:in `each'
    from org/jruby/RubyArray$i_method_0_0$RUBYFRAMEDINVOKER$each.gen:65535:in `call'
    from CachingCallSite.java:299:in `cacheAndCall'
    from CachingCallSite.java:117:in `callBlock'
    from CachingCallSite.java:122:in `call'
    from CallNoArgBlockNode.java:64:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedMethod.java:221:in `call'
    from DefaultMethod.java:190:in `call'
    from CachingCallSite.java:329:in `cacheAndCall'
    from CachingCallSite.java:188:in `call'
    from CallTwoArgNode.java:59:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from RescueNode.java:199:in `executeBody'
    from RescueNode.java:118:in `interpretWithJavaExceptions'
    from RescueNode.java:110:in `interpret'
    from BeginNode.java:83:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from InterpretedBlock.java:373:in `evalBlockBody'
    from InterpretedBlock.java:346:in `yield'
    from InterpretedBlock.java:303:in `yield'
    from Block.java:194:in `yield'
    from RubyArray.java:1630:in `eachCommon'
    from RubyArray.java:1637:in `each'
    from org/jruby/RubyArray$i_method_0_0$RUBYFRAMEDINVOKER$each.gen:65535:in `call'
    from CachingCallSite.java:299:in `cacheAndCall'
    from CachingCallSite.java:117:in `callBlock'
    from CachingCallSite.java:122:in `call'
    from CallNoArgBlockNode.java:64:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedMethod.java:139:in `call'
    from DefaultMethod.java:158:in `call'
    from CachingCallSite.java:289:in `cacheAndCall'
    from CachingCallSite.java:108:in `call'
    from VCallNode.java:85:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from IfNode.java:119:in `interpret'
    from IfNode.java:119:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedMethod.java:180:in `call'
    from DefaultMethod.java:174:in `call'
    from CachingCallSite.java:309:in `cacheAndCall'
    from CachingCallSite.java:148:in `call'
    from CallSpecialArgNode.java:67:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from CaseNode.java:138:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedMethod.java:180:in `call'
    from DefaultMethod.java:174:in `call'
    from CachingCallSite.java:309:in `cacheAndCall'
    from CachingCallSite.java:148:in `call'
    from FCallOneArgNode.java:36:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from RescueNode.java:199:in `executeBody'
    from RescueNode.java:118:in `interpretWithJavaExceptions'
    from RescueNode.java:110:in `interpret'
    from InterpretedMethod.java:180:in `call'
    from DefaultMethod.java:174:in `call'
    from CachingCallSite.java:309:in `cacheAndCall'
    from CachingCallSite.java:148:in `call'
    from CallOneArgNode.java:57:in `interpret'
    from NewlineNode.java:104:in `interpret'
    from BlockNode.java:71:in `interpret'
    from InterpretedMethod.java:180:in `call'
    from DefaultMethod.java:174:in `call'
    from CachingCallSite.java:309:in `cacheAndCall'
    from CachingCallSite.java:148:in `call'
    from gem:24:in `rescue_1$RUBY$__rescue___0'
    from gem:23:in `__file__'
    from gem:-1:in `load'
    from Ruby.java:692:in `runScript'
    from Ruby.java:575:in `runNormally'
    from Ruby.java:418:in `runFromMain'
    from Main.java:286:in `run'
    from Main.java:128:in `run'
    from Main.java:97:in `main'

既不是错误也不是成功消息。

1 个答案:

答案 0 :(得分:0)

根据对Jruby: NameError: uninitialized constant Neo4j的评论,我在require 'tabula'中尝试了irb

amanda@mona:tabula$ irb
irb(main):001:0> require 'tabula'
LoadError: no such file to load -- tabula
    from (irb):1:in `require'
    from (irb):1
    from :0
irb(main):002:0> 

这表明它没有安装。