0
0

More than 3 years have passed since last update.

PyCallがPyCall::PythonNotFoundで動かないとき

Last updated at Posted at 2021-01-13

rbenvでインストールしたRubyで、pyenvでインストールしたPythonを、pycallで呼ぼうとしたときPyCall::PythonNotFoundで落ちた。find_libpythonメソッドでlibpythonが見つけられていない様子。

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)

確認コマンドを実行する。

$ 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

static libraryをdlopenしようとしていて失敗している。shared libraryなlibpythonがインストールされるように、pyenvでPythonをインストールしなおす。

$ CONFIGURE_OPTS="--enable-shared" pyenv install 3.9.1

これで無事に動いた。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0