Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Errors on Ubuntu 16.10 #4

Closed
arbox opened this issue Mar 11, 2017 · 6 comments
Closed

Import Errors on Ubuntu 16.10 #4

arbox opened this issue Mar 11, 2017 · 6 comments

Comments

@arbox
Copy link

arbox commented Mar 11, 2017

Dear @mrkn ,

I'm trying to run examples from this repo, but I cannot go further the first require statement:

irb(main):001:0> require 'pycall/import'
LoadError: no library specified
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/ffi-1.9.18/lib/ffi/library.rb:176:in `ffi_libraries'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/ffi-1.9.18/lib/ffi/library.rb:336:in `attach_variable'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/pycall-0.1.0.alpha.20170311/lib/pycall/libpython.rb:106:in `<module:LibPython>'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/pycall-0.1.0.alpha.20170311/lib/pycall/libpython.rb:4:in `<module:PyCall>'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/pycall-0.1.0.alpha.20170311/lib/pycall/libpython.rb:3:in `<top (required)>'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/pycall-0.1.0.alpha.20170311/lib/pycall.rb:2:in `<top (required)>'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/pycall-0.1.0.alpha.20170311/lib/pycall/import.rb:1:in `<top (required)>'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `require'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from (irb):1
from /home/arbox/.rbenv/versions/2.4.0/bin/irb:11:in `<main>'

Setting PYTHONHOME and PYTHONPATH does not change the picture.

Could you please provide requirements for the Python side as well? Thank you!

@mrkn
Copy link
Owner

mrkn commented Mar 12, 2017

@arbox How do you install python?

Pycall uses PYTHON environment variable to find Python's executable such as /usr/bin/python3.
This environment variable is referred to execute investigator.py script, which investigates the installation directory and the path of shared library of the specified Python environment.

If you installed python into a non-standard location, please do either:

  • Specify the full-path of python command in PYTHON environment variable
  • Specify the name of python command in PYTHON and put the bin directory in PATH.

@arbox
Copy link
Author

arbox commented Mar 12, 2017

Hi, @mrkn, thank you for a reply!

Python is installed on my machine pretty standard, from the Ubuntu repositories.

I looked up your Travis configuration, so at least python python-dev python-all as well python3 python3-dev python3-all are installed. It's a fresh Ubuntu 16.10 installation.

I could run investigator.py manually with the following output:

executable: /usr/bin/python
exec_prefix: /usr
prefix: /usr
VERSION: 2.7
LIBRARY: libpython2.7.a
LDLIBRARY: libpython2.7.so
LIBDIR: /usr/lib
PYTHONFRAMEWORKPREFIX:

It seems to be a screwed Python installation here. But setting the environment as follows does not change the picture:

arbox@aplha:~/work_space/sandbox/pycall/pycall$ env | grep PYTHON
PYTHONHOME=/usr/lib/python2.7
PYTHONPATH=/usr/lib/python2.7
PYTHON=/usr/bin/python2.7

I've inspected the Hash which is returned by Pycall.investigate_python_config() in libpython.rb:

arbox@aplha:~/work_space/sandbox/pycall/pycall$ irb -I lib
irb(main):001:0> require 'pycall/import'
{:executable=>"/usr/bin/python2.7", :exec_prefix=>"/usr/lib/python2.7", :prefix=>"/usr/lib/python2.7", :VERSION=>"2.7", :LIBRARY=>"libpython2.7.a", :LDLIBRARY=>"libpython2.7.so", :LIBDIR=>"/usr/lib", :PYTHONFRAMEWORKPREFIX=>""}
LoadError: no library specified
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/ffi-1.9.18/lib/ffi/library.rb:176:in `ffi_libraries'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/ffi-1.9.18/lib/ffi/library.rb:336:in `attach_variable'
from /home/arbox/work_space/sandbox/pycall/pycall/lib/pycall/libpython.rb:109:in `<module:LibPython>'
from /home/arbox/work_space/sandbox/pycall/pycall/lib/pycall/libpython.rb:4:in `<module:PyCall>'
from /home/arbox/work_space/sandbox/pycall/pycall/lib/pycall/libpython.rb:3:in `<top (required)>'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/arbox/work_space/sandbox/pycall/pycall/lib/pycall.rb:2:in `<top (required)>'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/arbox/work_space/sandbox/pycall/pycall/lib/pycall/import.rb:1:in `<top (required)>'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/arbox/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from (irb):1
from /home/arbox/.rbenv/versions/2.4.0/bin/irb:11:in `<main>'

The value of the same hash without any env vars set:

{:executable=>"/usr/bin/python", :exec_prefix=>"/usr", :prefix=>"/usr", :VERSION=>"2.7", :LIBRARY=>"libpython2.7.a", :LDLIBRARY=>"libpython2.7.so", :LIBDIR=>"/usr/lib", :PYTHONFRAMEWORKPREFIX=>""}

Could I do something to provide you with additional debug info? Thank you!

@mrkn
Copy link
Owner

mrkn commented Mar 21, 2017

I could reproduce this issue with ubuntu 16.10 on VMware.
And I found the reason of this issue. It is due to multiarch support of Ubuntu (and Debian).

While Python said that the libdir is /usr/lib, but ubuntu's python package put libpython in /usr/lib/x86_64-linux-gnu.

Probably Python does not know libpython is located in /usr/lib/x86_64-linux-gnu.
If so, I cannot resolve the path of libpython from the information obtained by investigator.py.

@mrkn
Copy link
Owner

mrkn commented Mar 21, 2017

@arbox Now you can specify libpython's full path in LIBPYTHON environment variable.
On Ubuntu 16.10, LIBPYTHON=/usr/lib/x86_64-linux-gnu/libpython2.7.so.1 for Python 2.7 or LIBPYTHON=/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1 for Python 3.5 can be used.
Try again.

@mrkn mrkn closed this as completed Mar 21, 2017
@arbox
Copy link
Author

arbox commented Mar 21, 2017

@mrkn thank you! Cool support here! And very demanded library for Ruby :)

@mrkn
Copy link
Owner

mrkn commented Mar 29, 2017

@arbox I've released the new version of pycall. The latest pycall supports multiarch system in Debian and Ubuntu. Check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants