执行`poetry install -E sam`时pydantic-core(2.16.3)安装失败的问题求助
poetry install -E sam时pydantic-core(2.16.3)安装失败的问题求助 我正在搭建一个项目,按照README的说明操作,但卡在了执行poetry install -E sam这一步,命令输出了以下错误信息:
Installing dependencies from lock file
Package operations: 91 installs, 0 updates, 0 removals
- Installing pydantic-core (2.16.3): Failed
ChefBuildError
Backend subprocess exited when trying to invoke build_wheel
Runningmaturin pep517 build-wheel -i /private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpxt4446qb/.venv/bin/python --compatibility off Including license file "/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpz728d29q/pydantic_core-2.16.3/LICENSE"
Building a mixed python/rust project
Found pyo3 bindings
Found CPython 3.13 at /private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpxt4446qb/.venv/bin/python
Using build options features, bindings from pyproject.toml
UsingMACOSX_DEPLOYMENT_TARGET=11.0for aarch64-apple-darwin by default
Compiling ...
error: failed to run custom build command forpydantic-core v2.16.3 (/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpz728d29q/pydantic_core-2.16.3)Caused by:
process didn't exit successfully:/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpz728d29q/pydantic_core-2.16.3/target/release/build/pydantic-core-39a2e9245b501e5a/build-script-build(exit status: 101)--- stdout
cargo:rustc-cfg=Py_3_6
cargo:rustc-cfg=Py_3_7
cargo:rustc-cfg=Py_3_8
cargo:rustc-cfg=Py_3_9
cargo:rustc-cfg=Py_3_10
cargo:rustc-cfg=Py_3_11
cargo:rustc-cfg=Py_3_12
cargo:rustc-cfg=Py_3_13
cargo:rerun-if-changed=python/pydantic_core/core_schema.py
cargo:rerun-if-changed=generate_self_schema.py--- stderr Traceback (most recent call last): File "/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpz728d29q/pydantic_core-2.16.3/generate_self_schema.py", line 192, in eval_forward_ref return type_._evaluate(core_schema.__dict__, None, set()) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpz728d29q/pydantic_core-2.16.3/generate_self_schema.py", line 240, in <module> main() ~~~~^^ File "/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpz728d29q/pydantic_core-2.16.3/generate_self_schema.py", line 210, in main value = get_schema(s, definitions) File "/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpz728d29q/pydantic_core-2.16.3/generate_self_schema.py", line 54, in get_schema return type_dict_schema(obj, definitions) File "/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpz728d29q/pydantic_core-2.16.3/generate_self_schema.py", line 152, in type_dict_schema field_type = eval_forward_ref(field_type) File "/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpz728d29q/pydantic_core-2.16.3/generate_self_schema.py", line 195, in eval_forward_ref return type_._evaluate(core_schema.__dict__, None) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard' thread 'main' panicked at build.rs:29:9: generate_self_schema.py failed with exit status: 1 note: run with `RUST_BACKTRACE=1` environment variable to display a backtracewarning: build failed, waiting for other jobs to finish...
maturin failed
Caused by: Failed to build a native library through cargo
Caused by: Cargo build finished with "exit status: 101":env -u CARGO MACOSX_DEPLOYMENT_TARGET="11.0" PYO3_ENVIRONMENT_SIGNATURE="cpython-3.13-64bit" PYO3_PYTHON="/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpxt4446qb/.venv/bin/python" PYTHON_SYS_EXECUTABLE="/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpxt4446qb/.venv/bin/python" "cargo" "rustc" "--features" "pyo3/extension-module" "--message-format" "json-render-diagnostics" "--manifest-path" "/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpz728d29q/pydantic_core-2.16.3/Cargo.toml" "--release" "--lib" "--crate-type" "cdylib" "--" "-C" "link-arg=-undefined" "-C" "link-arg=dynamic_lookup" "-C" "link-args=-Wl,-install_name,@rpath/pydantic_core._pydantic_core.cpython-313-darwin.so"
Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/private/var/folders/wc/58gd_dz17b54xr8094v5ss100000gq/T/tmpxt4446qb/.venv/bin/python', '--compatibility', 'off'] returned non-zero exit status 1at ~/.local/pipx/venvs/poetry/lib/python3.13/site-packages/poetry/installation/chef.py:164 in _prepare
160│
161│ error = ChefBuildError("\n\n".join(message_parts))
162│
163│ if error is not None:
→ 164│ raise error from None
165│
166│ return path
167│
168│ def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:Note: This error originates from the build backend, and is likely not a problem with poetry but with pydantic-core (2.16.3) not supporting PEP 517 builds. You can verify this by running
pip wheel --no-cache-dir --use-pep517 "pydantic-core (==2.16.3)".
我尝试用ChatGPT调试这个问题,它建议我更换Python版本。我修改了项目设置,改用Python 3.12,但看起来还有其他地方需要调整——因为错误信息里仍然显示"Found CPython 3.13"。
额外信息:不知道有没有帮助,在出现这个错误之前,执行同一个命令时会安装另一个包失败,提示"Installing rpds-py (0.18.0): Failed"。ChatGPT建议我安装Rust,这个办法成功解决了那个问题,命令得以继续安装后续包,但现在卡在了pydantic-core这里。
备注:内容来源于stack exchange,提问作者Ioakim Ioakim




