hyperon-experimental: REPL cannot load `libpython` when built and run under Python environment

I use Conda environment to manage Python versions and dependencies. When I build MeTTa REPL under Conda and try to run it after the build I see the following error:

$ ./target/debug/metta 
./target/debug/metta: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory

PyO3 compile against and uses absolutely correct version of the Python library. I don’t see any inconsistency here.

According to https://github.com/PyO3/pyo3/issues/1576 when using PyO3 app under Python env one need to add the path to the Python library into LD_LIBRARY_PATH. This kind of works but breaks other executables because lib directory in Conda env contains other libraries which overrides system library loading paths.

Steps to reproduce (Conda is expected to be installed):

conda create -n test python=3.7
conda activate test
cd repl
cargo run --features python

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 20 (9 by maintainers)

Most upvoted comments

Yes. It’s fundamentally a Python issue, not specific to PyEnv or Conda. It’s not even really Pyo3’s fault as it’s doing what any other application is supposed to do to load a library.

The fact that Python’s compatibility solution requires multiple entire separate virtual environments is the source of the issue.

If we want to fix this we have to “enter through the door” provided by the environment manager. ie. probably by locating the python executable by scanning directories in the $PATH environment variable. (or letting the shell do that)