Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
velvia opened this issue Apr 19, 2021 · 2 comments

Comments

@velvia
Copy link

velvia commented Apr 19, 2021

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

  • Your operating system and version: MacOS 10.15.7
  • Your python version: 3.7.7
  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?: pyenv
  • Your Rust version (rustc --version):
  • 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")?:

💥 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
Copy link
Member

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, #742 (comment)

@davidhewitt
Copy link
Member

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

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

No branches or pull requests

2 participants