Skip to content

Python shared object not found while using pyenv #1576

Open
@lainisourgod

Description

🐛 Python shared object not found while using pyenv

🌍 Environment

  • Your operating system and version: Windows 10 20h2 + WSL2
  • Your python version: 3.7.9
  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?: env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.9
  • Your Rust version (rustc --version): rustc 1.51.0 (2fd73fabe 2021-03-23)
  • Your PyO3 version: *0.13.2
  • Have you tried using latest PyO3 main (replace version = "0.x.y" with git = "https://github.com/PyO3/pyo3")?: yes

💥 Reproducing

main.rs

use pyo3::prelude::*;
use pyo3::types::IntoPyDict;

fn main() -> Result<(), ()> {
    Python::with_gil(|py| {
        main_(py).map_err(|e| {
            // We can't display Python exceptions via std::fmt::Display,
            // so print the error here manually.
            e.print_and_set_sys_last_vars(py);
        })
    })
}

fn main_(py: Python) -> PyResult<()> {
    let sys = py.import("sys")?;
    let version: String = sys.get("version")?.extract()?;
    let locals = [("os", py.import("os")?)].into_py_dict(py);
    let code = "os.getenv('USER') or os.getenv('USERNAME') or 'Unknown'";
    let user: String = py.eval(code, None, Some(&locals))?.extract()?;
    println!("Hello {}, I'm Python {}", user, version);
    Ok(())
}

cargo run

Result

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

Workaround

export LD_LIBRARY_PATH=~/.pyenv/versions/3.7.9/lib

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions