In Ruby installed by rbenv, when I tried to call Python installed by pyenv with pycall, it failed with PyCall :: PythonNotFound. It seems that libpython is not found by the find_libpython method.
Traceback (most recent call last):
5: from hoge.rb:4:in `<main>'
4: from /Users/fuga/.anyenv/envs/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pycall-1.3.1/lib/pycall/import.rb:18:in `pyimport'
3: from /Users/fuga/.anyenv/envs/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pycall-1.3.1/lib/pycall.rb:62:in `import_module'
2: from /Users/fuga/.anyenv/envs/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pycall-1.3.1/lib/pycall/init.rb:16:in `const_missing'
1: from /Users/fuga/.anyenv/envs/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pycall-1.3.1/lib/pycall/init.rb:35:in `init'
/Users/fuga/.anyenv/envs/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/pycall-1.3.1/lib/pycall/libpython/finder.rb:95:in `find_libpython': PyCall::PythonNotFound (PyCall::PythonNotFound)
Execute the confirmation command.
$ PYCALL_DEBUG_FIND_LIBPYTHON=1 ruby -rpycall -ePyCall.builtins
...
DEBUG(find_libpython) Fiddle::DLError: dlopen(libpython3.9.a, 9): image not found
DEBUG(find_libpython) Fiddle::DLError: dlopen(libpython3.9, 9): image not found
DEBUG(find_libpython) Fiddle::DLError: dlopen(libpython, 9): image not found
Attempting to dlopen the static library has failed. Reinstall Python with pyenv so that the shared library libpython is installed.
$ CONFIGURE_OPTS="--enable-shared" pyenv install 3.9.1
It worked fine.
Recommended Posts