libpython fails to load on 64-bit CentOS 5.5
halostatue opened this issue · 0 comments
While trying to use rubypython 0.5.1 on CentOS 5.5, Ruby 1.8.7 and Python 2.4, I ran into this error -
{{{
#!ruby
/home/amujumdar/.rvm/gems/ruby-1.8.7-p334@ohloh-rails-2.3/gems/ffi-1.0.9/lib/ffi/library.rb:76:in ffi_lib': Could not open library 'lib.so': lib.so: cannot open shared object file: No such file or directory (LoadError) from /home/amujumdar/.rvm/gems/ruby-1.8.7-p334@ohloh-rails-2.3/gems/ffi-1.0.9/lib/ffi/library.rb:55:in
map'
from /home/amujumdar/.rvm/gems/ruby-1.8.7-p334@ohloh-rails-2.3/gems/ffi-1.0.9/lib/ffi/library.rb:55:in ffi_lib' from /home/amujumdar/.rvm/gems/ruby-1.8.7-p334@ohloh-rails-2.3/gems/rubypython-0.5.1/lib/rubypython/python.rb:31 from /home/amujumdar/.rvm/gems/ruby-1.8.7-p334@ohloh-rails-2.3/gems/rubypython-0.5.1/lib/rubypython.rb:261:in
load'
from /home/amujumdar/.rvm/gems/ruby-1.8.7-p334@ohloh-rails-2.3/gems/rubypython-0.5.1/lib/rubypython.rb:261:in reload_library' from /home/amujumdar/.rvm/gems/ruby-1.8.7-p334@ohloh-rails-2.3/gems/rubypython-0.5.1/lib/rubypython.rb:104:in
start'
}}}
Turned out, 64-bit Python shared libraries are located in /usr/lib64/, which is not one of the paths rubypython looks into.
To fix this error, I added this location to
{{{
#!ruby
if FFI::Platform.unix?
# On Unixes, let's look in some standard alternative places, too.
# Just in case. Some Unixes don't include a .so symlink when they
# should, so let's look for the base case of .so.1, too.
[ libname, "#{libname}.1" ].each do |name|
locations << File.join("/opt/local/lib", name)
locations << File.join("/opt/lib", name)
locations << File.join("/usr/local/lib", name)
locations << File.join("/usr/lib", name)
locations << File.join("/usr/lib64", name)
end
end
}}}
in rubypython-0.5.1/lib/rubypython/pythonexec.rb, find_python_lib method.