PyO3 / pyo3

Rust bindings for the Python interpreter
https://pyo3.rs
Apache License 2.0
12.19k stars 752 forks source link

Docs: workaround for `auto-initialize feature is not supported when linking Python statically` #1568

Closed velvia closed 3 years ago

velvia commented 3 years ago

I get this error when trying the workaround in the FAQ (https://pyo3.rs/master/faq.html#i-cant-run-cargo-test-im-having-linker-issues-like-symbol-not-found-or-undefined-reference-to-_pyexc_systemerror)

cargo test --no-default-features
   Compiling pyo3 v0.13.2
error: The `auto-initialize` feature is not supported when linking Python statically instead of with a shared library.

Please disable the `auto-initialize` feature, for example by entering the following in your cargo.toml:

    pyo3 = { version = "0.13.2", default-features = false }

Alternatively, compile PyO3 using a Python distribution which contains a shared libary.
   --> /Users/evan/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-0.13.2/src/gil.rs:221:17
    |
221 | /                 compile_error!(concat!(
222 | |                     "The `auto-initialize` feature is not supported when linking Python ",
223 | |                     "statically instead of with a shared library.\n\n",
224 | |                     "Please disable the `auto-initialize` feature, for example by entering the following ",
...   |
230 | |                     "libary."
231 | |                 ));
    | |___________________^

error: aborting due to previous error

🌍 Environment

💥 Reproducing

Please provide a minimal working example. This means both the Rust code and the Python.

Please also write what exact flags are required to reproduce your results.

Workaround (please add this to the FAQ/troubleshooting page):

Re-install Python in pyenv using --enable-shared configuration: https://github.com/pyenv/pyenv/wiki#how-to-build-cpython-with---enable-shared

Rebuild pyo3 using cargo clean etc.

davidhewitt commented 3 years ago

Thanks, agreed that some improvement can be made here. I've been planning for a while to find some time to write better instructions on "getting started with pyo3", which would include installation notes for pyenv.

For a bit of history, see #763, https://github.com/PyO3/pyo3/issues/742#issuecomment-577332616

davidhewitt commented 3 years ago

A complete rewrite of this error message was done in #1553, so I think we can call this resolved for now.