1

我正在尝试在 Debian 8 上使用 RubyPython,但一直无法使用。RubyPython.start总是引发InvalidInterpreter异常。我试过指定python解释器可执行文件,但这没关系。下面的片段显示了我的版本并尝试从 pry 启动它

rubypython (0.6.3)
adrew@bunny:~$ ruby --version
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
adrew@bunny:~$ python --version
Python 2.7.9
adrew@bunny:~$ which python2.7
/usr/bin/python2.7
adrew@bunny:~$ pry
[1] pry(main)> require 'rubypython'
=> true
[2] pry(main)> RubyPython.start
RubyPython::InvalidInterpreter: An invalid interpreter was specified.
from /var/lib/gems/2.1.0/gems/rubypython-0.6.3/lib/rubypython.rb:67:in `block in start'
[3] pry(main)> RubyPython.start(:python_exe => "/usr/bin/python2.7")
RubyPython::InvalidInterpreter: An invalid interpreter was specified.
from /var/lib/gems/2.1.0/gems/rubypython-0.6.3/lib/rubypython.rb:67:in `block in start'
4

2 回答 2

1

我跑去strace -ff -o /tmp/pry.txt pry看看当require rubypythonRubyPython.start被输入时会发生什么。有类似的线条

stat("/usr/lib/libpython2.7.so", 0x7ffd2bf4cde0) = -1 ENOENT (No such file or directory)

这意味着 ruby​​python 代码试图定位 python 库。缺少的是stat/usr/lib/x86_64-linux-gnu/libpython2.7.so 文件的成功。

我修改了文件 ~/.gem/ruby/2.1.0/gems/rubypython-0.6.3/lib/rubypython/interpreter.rb

if ::FFI::Platform::ARCH != 'i386'
   @locations << File.join("/opt/local/lib64", name)
   @locations << File.join("/opt/lib64", name)
   @locations << File.join("/usr/local/lib64", name)
   @locations << File.join("/usr/lib64", name)
   @locations << File.join("/usr/lib/x86_64-linux-gnu", name)

最后一行是我插入的内容。在这之后RubyPython.start返回true

于 2016-07-16T06:30:14.833 回答
0

更新RubyPython0.6.4版本为我解决了这个问题。

于 2018-01-31T06:46:43.507 回答