首页 > 解决方案 > 在 64 位 Mac OSX 上的 64 位 python 解释器上构建“orjson”时,requirement.txt 安装失败

问题描述

为项目运行 requirements.txt 安装(快速 API)。以以下错误结束。我已经尝试了来自https://github.com/rust-lang/rust/issues/61925的方法, 并且我已经将 rust 设置为“夜间”使用rustup override set nightly仍然面临错误。

  Using cached orjson-3.4.3.tar.gz (1.2 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/local/opt/python@3.8/bin/python3.8 /usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/c7/0n1qpwb16l55dfdwqs4xt97dhw2m6y/T/tmpwyr1rz66
         cwd: /private/var/folders/c7/0n1qpwb16l55dfdwqs4xt97dhw2m6y/T/pip-install-qmnttz7p/orjson
    Complete output (13 lines):
     maturin failed
      Caused by: Cargo metadata failed. Do you have cargo in your PATH?
      Caused by: Error during execution of `cargo metadata`: error: failed to run `rustc` to learn about target-specific information
    
    Caused by:
      process didn't exit successfully: `rustc - --crate-name ___ --print=file-names -Z mutable-noalias --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit code: 1)
      --- stderr
      error: the option `Z` is only accepted on the nightly compiler
    
    
    Checking for Rust toolchain....
    Running `maturin pep517 write-dist-info --metadata-directory /private/var/folders/c7/0n1qpwb16l55dfdwqs4xt97dhw2m6y/T/pip-modern-metadata-c1upg8fc --interpreter /usr/local/Cellar/python@3.8/3.8.6_2/bin/python3.8 --manylinux=off --strip=on`
    Error: Command '['maturin', 'pep517', 'write-dist-info', '--metadata-directory', '/private/var/folders/c7/0n1qpwb16l55dfdwqs4xt97dhw2m6y/T/pip-modern-metadata-c1upg8fc', '--interpreter', '/usr/local/Cellar/python@3.8/3.8.6_2/bin/python3.8', '--manylinux=off', '--strip=on']' returned non-zero exit status 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/python@3.8/bin/python3.8 /usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/c7/0n1qpwb16l55dfdwqs4xt97dhw2m6y/T/tmpwyr1rz66 Check the logs for full command output.

请指教!谢谢!

标签: pythonmacosrustfastapirustup

解决方案


似乎错误与使用“Z”选项的 maturin 命令有关,该选项仅适用于夜间编译器。你可以先尝试安装

安装夜间工具链:

rustup 每晚安装

切换到 nightly 工具链作为默认工具链:

rustup 默认每晚

然后尝试安装这些依赖项。希望这有效!!!!


推荐阅读