PyO3 / PyO3/pyo3

Can't call Python from Rust with pyenv

Open
#2,803 9 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.2k
Forks
1k
Avg merge
2d 6h
Merged PRs (30d)
66

Description

OS: PopOs (Ubuntu) 22.04
System Python: python3 3.10

Steps:

PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.9.16
pyenv virtualenv 3.9.16 test
pyenv activate test
cargo run

Output:

     Running `target/debug/noos-serve`
target/debug/noos-serve: error while loading shared libraries: libpython3.9.so.1.0: cannot open shared object file: No such file or directory

Now some info:

PYO3_PRINT_CONFIG=1 cargo build

Output:

PYO3_PRINT_CONFIG=1 cargo build
   Compiling pyo3-ffi v0.17.3
error: failed to run custom build command for `pyo3-ffi v0.17.3`

Caused by:
  process didn't exit successfully: `/home/nathaniel/Projects/noos/monoos/noos-serve/target/debug/build/pyo3-ffi-7798a5823d368cc3/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=PYO3_CROSS
  cargo:rerun-if-env-changed=PYO3_CROSS_LIB_DIR
  cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_VERSION
  cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_IMPLEMENTATION
  cargo:rerun-if-env-changed=PYO3_PRINT_CONFIG

  -- PYO3_PRINT_CONFIG=1 is set, printing configuration and halting compile --
  implementation=CPython
  version=3.9
  shared=true
  abi3=false
  lib_name=python3.9
  lib_dir=/home/nathaniel/.pyenv/versions/3.9.16/lib
  executable=/home/nathaniel/.pyenv/versions/test/bin/python
  pointer_width=64
  build_flags=
  suppress_build_script_link_lines=false

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the pyenv and cargo run commands on the reported Pop!_OS/Ubuntu setup, then inspect the pyo3-ffi build output produced by PYO3_PRINT_CONFIG=1. Compare the reported lib_dir and lib_name with the runtime loader failure; done means identifying whether PyO3 needs a repository-level fix or the issue is environment-specific.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.