[RUBY] When PyCall doesn't work with PyCall :: PythonNotFound

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

When PyCall doesn't work with PyCall :: PythonNotFound
@ClassRules doesn't work with PowerMockRunner
Things to check when it doesn't work with proguard
[Beginner] When rails s doesn't work
Check when nvidia-smi on Ubuntu doesn't work
SCSS doesn't work when deploying Rails6 AWS
When the vagrant command doesn't work for some reason
Summary of initial work when creating an app with Rails
The program doesn't work, the program doesn't stop ...
Automate your work with Rake
ruby get.chomp.to_i doesn't work, doesn't load
Arrays.asList (int []). Contains (int) doesn't work
What to do if validation doesn't work with the update action
Links I want to help when JSF doesn't work at all
When Maven is blocked by a company proxy and doesn't work
Breakpoint doesn't work when running Rails Minitest in Ruby Test Explorer