libpython fails to load on 64-bit CentOS 5.5

amujumdar avataramujumdar created an issue

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 -

/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

    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.

Comments (3)

  1. chen qian

    and in my ubuntu 13.10 vmware workstation, the library are located in /usr/lib/python2.7/config-x86_64-linux-gnu/, I think the gem should provide an api to set
    the lib path by myself

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.