Open lainisourgod opened 3 years ago
Thanks for reporting. It's expected that you will need to set LD_LIBRARY_PATH
, however I agree the documentation could make this clearer. I'll try to add something.
I've created this build.rs
script to fix the problem for me:
fn main() {
let home = std::env::var("HOME").expect("${HOME} is missing");
println!("cargo:rustc-env=LD_LIBRARY_PATH={home}/.pyenv/versions/3.11.2/lib");
}
I found trying to use a cargo config with a home reference/variable wasn't resolving and I didn't want to hard-code the path.
I used https://github.com/pyenv/pyenv/issues/2647#issuecomment-1511754155, inside .bashrc or .zshrc:
for version in $(pyenv versions --bare)
do
export LD_LIBRARY_PATH="$(pyenv root)/versions/$version/lib:$LD_LIBRARY_PATH"
done
🐛 Python shared object not found while using pyenv
🌍 Environment
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.9
rustc --version
): rustc 1.51.0 (2fd73fabe 2021-03-23)version = "0.x.y"
withgit = "https://github.com/PyO3/pyo3")?
: yes💥 Reproducing
main.rs
cargo run
Result
error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory
Workaround