[Python] Can't set Python version when running rust-analyzer and PyO3 on WSL

Discussão em 'Python' iniciado por Stack, Maio 18, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to tell PyO3 to use Python 3.11 by setting the environment variable PYTHON_SYS_EXECUTABLE, but Python 3.6 continues to be used, which is too old a version for PYO3, and so proc-macros fail. I am running on a Windows 11 machine and using a WSL RedHat 8 distro. I've tried ensuring that VS Code inherits the environment variable, and it does seem to, but still rust analyzer crashes and tells me :

    error: failed to run custom build command for `pyo3-ffi v0.23.5`
    note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

    Caused by:
    process didn't exit successfully: `/tools/rust/target/debug/build/pyo3-ffi-0d4cba8584d692ee/build-script-build` (exit status: 1)
    --- stdout
    cargo:rustc-check-cfg=cfg(Py_LIMITED_API)
    cargo:rustc-check-cfg=cfg(Py_GIL_DISABLED)
    cargo:rustc-check-cfg=cfg(PyPy)
    cargo:rustc-check-cfg=cfg(GraalPy)
    cargo:rustc-check-cfg=cfg(py_sys_config, values("Py_DEBUG", "Py_REF_DEBUG", "Py_TRACE_REFS", "COUNT_ALLOCS"))
    cargo:rustc-check-cfg=cfg(invalid_from_utf8_lint)
    cargo:rustc-check-cfg=cfg(pyo3_disable_reference_pool)
    cargo:rustc-check-cfg=cfg(pyo3_leak_on_drop_without_reference_pool)
    cargo:rustc-check-cfg=cfg(diagnostic_namespace)
    cargo:rustc-check-cfg=cfg(c_str_lit)
    cargo:rustc-check-cfg=cfg(rustc_has_once_lock)
    cargo:rustc-check-cfg=cfg(fn_ptr_eq)
    cargo:rustc-check-cfg=cfg(Py_3_7)
    cargo:rustc-check-cfg=cfg(Py_3_8)
    cargo:rustc-check-cfg=cfg(Py_3_9)
    cargo:rustc-check-cfg=cfg(Py_3_10)
    cargo:rustc-check-cfg=cfg(Py_3_11)
    cargo:rustc-check-cfg=cfg(Py_3_12)
    cargo:rustc-check-cfg=cfg(Py_3_13)
    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

    --- stderr
    error: the configured Python interpreter version (3.6) is lower than PyO3's minimum supported version (3.7)

    Continue reading...

Compartilhe esta Página