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

Initialization failure in MacOS + homebrew + pyenv #92

Closed
camlspotter opened this issue Jan 31, 2023 · 2 comments
Closed

Initialization failure in MacOS + homebrew + pyenv #92

camlspotter opened this issue Jan 31, 2023 · 2 comments

Comments

@camlspotter
Copy link

Under MacOS + homebrew + pyenv, I fail to initialize pyml:

let () = Py.initialize () fails with the following error message:

% pyenv local 3.10.9
% dune exec ./mytest.exe
Entering directory '/Users/jun/pyml'
Done: 60% (3/5, 2 left) (jobs: 0)Fatal error: exception Failure("Py.find_library: unable to find the Python library [libpython3.10m.dylib returned dlopen(libpython3.10m.dylib, 0x0009): tried: 'libpython3.10m.dylib' (no such file), '/usr/local/lib/libpython3.10m.dylib' (no such file), '/usr/lib/libpython3.10m.dylib' (no such file), '/Users/jun/pyml/mytest/libpython3.10m.dylib' (no such file)] [/opt/homebrew/lib/libpython3.10m.dylib returned dlopen(/opt/homebrew/lib/libpython3.10m.dylib, 0x0009): tried: '/opt/homebrew/lib/libpython3.10m.dylib' (no such file)] [libpython3.10.dylib returned dlopen(libpython3.10.dylib, 0x0009): tried: 'libpython3.10.dylib' (no such file), '/usr/local/lib/libpython3.10.dylib' (no such file), '/usr/lib/libpython3.10.dylib' (no such file), '/Users/jun/pyml/mytest/libpython3.10.dylib' (no such file)] [/opt/homebrew/lib/libpython3.10.dylib returned dlopen(/opt/homebrew/lib/libpython3.10.dylib, 0x0009): tried: '/opt/homebrew/lib/libpython3.10.dylib' (no such file)]")

The library to be found, libpython3.10.dynlib is at$HOME/.pyenv//versions/3.10.9/lib/libpython3.10.dylib, but pyml cannot find it. It executes python-config --ldflags to locate the library directory but under my environment, MacOS + homebrew + pyenv, it prints something unexpected for pyml:

% python-config --ldflags
-lintl -ldl -L/opt/homebrew/lib -Wl,-rpath,/opt/homebrew/lib -framework CoreFoundation

FYI, I use the following quick fix to locate the correct directory $HOME/.pyenv/versinos/3.10.9/lib by executing python-config --prefix instead of python-config --ldflags: https://gitlab.com/dailambda/pyml/-/commit/b09f7160dd232eba5784f8553e44ea86d8ddbdda (Sorry this is not GitHub but GitLab).

thierry-martinez added a commit that referenced this issue Jun 24, 2023
…_pyenv

Fix #92: Better heuristics for finding python library with pyenv
@thierry-martinez
Copy link
Owner

Thanks a lot for the report and sorry for the delay. This should be fixed now.

@camlspotter
Copy link
Author

Thanks!

thierry-martinez added a commit that referenced this issue Oct 30, 2023
Suggested by camlspotter.
#92
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