使用pip安装包的问题:“Cargo,Rust包管理器,未安装或不在PATH上”

lfapxunr  于 12个月前  发布在  Go
关注(0)|答案(7)|浏览(571)

我正在使用Python虚拟环境进行一个项目。在设置好venv并从git中拉取后,我尝试pip install -r requirements.txt,但得到以下错误:

Collecting orjson==3.5.2
  Using cached orjson-3.5.2.tar.gz (740 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]

      Cargo, the Rust package manager, is not installed or is not on PATH.
      This package requires Rust and Cargo to compile extensions. Install it through
      the system's package manager or via https://rustup.rs/

      Checking for Rust toolchain....
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

字符串
我使用的是Python 3.10.2版,pip 22.0.4版。
有什么办法解决这个问题吗?我安装了生 rust ,但它没有解决。
我没有得到下面的错误后,移动我的虚拟环境到本地。

Collecting orjson==3.5.2
  Using cached orjson-3.5.2.tar.gz (740 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      💥 maturin failed
        Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
        Caused by: `cargo metadata` exited with an error: 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=yes --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
      Error running maturin: Command '['maturin', 'pep517', 'write-dist-info', '--metadata-directory', 'C:\\Users\\jawan\\AppData\\Local\\Temp\\pip-modern-metadata-hjcwzhua', '--interpreter', 'C:\\Users\\jawan\\Desktop\\Programming\\imotor\\Scripts\\python.exe', '--manylinux=off', '--strip=on']' returned non-zero exit status 1.
      Checking for Rust toolchain....
      Running `maturin pep517 write-dist-info --metadata-directory C:\Users\jawan\AppData\Local\Temp\pip-modern-metadata-hjcwzhua --interpreter C:\Users\jawan\Desktop\Programming\imotor\Scripts\python.exe --manylinux=off --strip=on`
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

sigwle7e

sigwle7e1#

尝试安装Rust编程语言的工具,因为看起来你有一个使用Rust的依赖项。
对于Mac OS,我建议使用brew

brew install rust

字符串
否则使用Rust install page中的步骤。
您可以通过以下方式检查防 rust 是否安装正确:

rustc --version


完成后,再次尝试pip安装您的需求文件。

lf5gs5x2

lf5gs5x22#

在新创建的环境中升级我的pip发行版首先解决了我的问题:

pip install --upgrade pip

字符串

k75qkfdt

k75qkfdt3#

我遇到了类似的问题,在安装了64位版本的Python之后,一切都很好。

dgsult0t

dgsult0t4#

只需安装依赖项:

curl https://sh.rustup.rs -sSf | sh

字符串
来源:https://doc.rust-lang.org/cargo/getting-started/installation.html

vhipe2zx

vhipe2zx5#

您需要使用VS 2022控制台的x64 Native Tools命令提示符来执行命令“pip install open interpreter”

ars1skjm

ars1skjm6#

我已经有了一个64位版本的Python(如this other answer中所提到的),但我仍然面临着同样的问题。我升级了pip,然后一切都很好。我不必安装Rust。

qacovj5a

qacovj5a7#

上述错误是由一个生 rust 的包引起的

pywinpty

字符串
所有你需要做的就是从requirements.txt文件中删除它并重新部署你的应用。

相关问题