我正在尝试在Debian 8上使用RubyPython,但一直无法使用。 RubyPython.start
总是引发InvalidInterpreter
异常。我试过指定python解释器可执行文件,但这没关系。下面的片段显示了我的版本,并尝试从撬动中启动
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 rubypython
和RubyPython.start
时会发生什么。有像
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
。我修改了文件〜/ .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
。关于python - Ruby 2.1.5和RubyPython 0.6.3- RubyPython::InvalidInterpreter:指定了无效的解释器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38400748/