我正在尝试在Mac OS X Yosemite上安装pdf-extract。我认为最好不要使用Yosemite附带的/usr/bin/ruby
,所以我使用的是Macports版本/opt/local/bin/ruby
(版本2.1.3)。
安装似乎没问题:
sudo port install ruby
sudo port install rb-rubygems
sudo port select --set ruby ruby21
which ruby #/opt/local/bin/ruby
which gem #/opt/local/bin/gem
sudo gem install pdf-extract
在最后一个命令的末尾,显示的消息表明一切顺利:
...
Done installing documentation for Ascii85, afm, commander, hashery, highline, libsvm-ruby-swig, mini_portile, nokogiri, pdf-core, pdf-extract, pdf-reader, prawn, ruby-rc4, sqlite3, ttfunk after 30 seconds
15 gems installed
但是,当我尝试运行pdf-extract时,遇到了以下错误:
$ cd bin/
$ ./pdf-extract extract --titles journal.pdf
/opt/local/lib/ruby2.1/gems/2.1.0/gems/commander-4.2.1/lib/commander/runner.rb:384:in `block in require_program': program version required (Commander::Runner::CommandError)
from /opt/local/lib/ruby2.1/gems/2.1.0/gems/commander-4.2.1/lib/commander/runner.rb:383:in `each'
from /opt/local/lib/ruby2.1/gems/2.1.0/gems/commander-4.2.1/lib/commander/runner.rb:383:in `require_program'
from /opt/local/lib/ruby2.1/gems/2.1.0/gems/commander-4.2.1/lib/commander/runner.rb:51:in `run!'
from /opt/local/lib/ruby2.1/gems/2.1.0/gems/commander-4.2.1/lib/commander/delegates.rb:8:in `run!'
from /opt/local/lib/ruby2.1/gems/2.1.0/gems/commander-4.2.1/lib/commander/import.rb:10:in `block in <top (required)>'
/private/tmp/pdfextract/lib/pdf/extract/references/score.rb:11:in `<module:Score>': uninitialized constant Libsvm::Model (NameError)
from /private/tmp/pdfextract/lib/pdf/extract/references/score.rb:4:in `<module:PdfExtract>'
from /private/tmp/pdfextract/lib/pdf/extract/references/score.rb:3:in `<top (required)>'
from /private/tmp/pdfextract/lib/pdf/extract/references/references.rb:3:in `require_relative'
from /private/tmp/pdfextract/lib/pdf/extract/references/references.rb:3:in `<top (required)>'
from /private/tmp/pdfextract/lib/pdf/extract.rb:10:in `require_relative'
from /private/tmp/pdfextract/lib/pdf/extract.rb:10:in `<top (required)>'
from /private/tmp/pdfextract/lib/pdf-extract.rb:1:in `require_relative'
from /private/tmp/pdfextract/lib/pdf-extract.rb:1:in `<top (required)>'
from ./pdf-extract:5:in `require_relative'
from ./pdf-extract:5:in `<main>'
我的问题是我是否正确地完成了gem install
(因此它可能是pdf-extract
中的错误)或者我是否搞砸了安装(或在文件路径中)。
附注:安装文件夹最初是$HOME/Dropbox/code/ruby/pdf-extract
,但我执行了mv pdf-extract /tmp
(以缩短错误消息中的文件路径)并重新运行安装脚本(基本上是错误消息)保持不变)。我还尝试将./pdf-extract
替换为/opt/local/bin/ruby2.1 pdf-extract
,但它没有帮助。