本文介绍了Ruby 2.1.5和RubyPython 0.6.3- RubyPython :: InvalidInterpreter:指定了无效的解释器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to use RubyPython on Debian 8 and have been unable to. RubyPython.start always raises an InvalidInterpreter exception. I've tried specifying the python interpreter executable but it doesn't matter. The snipped below shows my versions and attempting to start it from 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'

推荐答案

我运行strace -ff -o /tmp/pry.txt pry来查看输入require rubypythonRubyPython.start时会发生什么.有这样的行

I run strace -ff -o /tmp/pry.txt pry to see what happens when require rubypython and RubyPython.start are entered. There was lines like

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

表示rubypython代码正在尝试定位python库.缺少的是/usr/lib/x86_64-linux-gnu/libpython2.7.so文件成功的stat.

meaning that rubypython code was trying to locate python library. What was absent was a successful stat for /usr/lib/x86_64-linux-gnu/libpython2.7.so file.

我修改了文件〜/.gem/ruby​​/2.1.0/gems/ruby​​python-0.6.3/lib/ruby​​python/interpreter.rb

I modified file ~/.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.

where the last line is what I inserted. After this RubyPython.start returned true.

这篇关于Ruby 2.1.5和RubyPython 0.6.3- RubyPython :: InvalidInterpreter:指定了无效的解释器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 05:23