使用 pip 安装软件包时出现问题:“Cargo,Rust 软件包管理器,未安装或不在 PATH 上”

发布于 2025-01-18 06:59:05 字数 3195 浏览 1 评论 0原文

我正在使用 Python 虚拟环境来处理项目。设置 venv 并从 git 拉取后,我尝试 pip install -rrequirements.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.

I am using a Python virtual environment to work on a project. After setting up my venv and pulling from git I tried to pip install -r requirements.txt but am getting the following error:

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.

I am using Python version 3.10.2, pip version 22.0.4.

Any idea how to fix this? I installed rust but it did not fix it.

I am not getting the errors below after moving my virtual enviroment to local.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

不甘平庸 2025-01-25 06:59:05

尝试为Rust编程语言安装工具,因为您似乎有一种使用Rust的依赖性。

对于Mac OS,我建议使用 brew

brew install rust

否则,请使用 rust安装页面的步骤。

您可以检查适当安装RUST:

rustc --version

完成后,一旦完成,请重新尝试安装需求文件。

Try installing the tooling for the Rust programming language, because it seems like you have a dependency that uses Rust.

For mac OS, I recommend using brew.

brew install rust

Otherwise use the steps from the Rust install page.

You can check that rust is installed properly with:

rustc --version

Once you are finished try again to pip install your requirements file.

浅紫色的梦幻 2025-01-25 06:59:05

我对Docker Image Python遇到了同样的问题:3.12-Alpine。这个答案是我发现的第一个答案。当我尝试将Rust编译器安装在高山容器上时,我的PIP包(Solana依赖性 - 焊料)永远花费了编译。我发现的唯一解决方案是使用python:3.12-book虫。它不需要任何汇编或生锈安装。它只是开箱即用。希望我的答案可以帮助某人节省一些晚上。

I had the same issue with the docker image python:3.12-alpine. This answer was the first one I found. When I tried to install the rust compiler on the alpine container, my pip package (solana dependency - solders) took forever to compile. The only solution I found was to use python:3.12-bookworm instead. It didn’t require any compilation or rust installation. It just worked out of the box. I hope my answer helps someone save a few evenings.

梦年海沫深 2025-01-25 06:59:05

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

pip install --upgrade pip

Upgrading my pip distribution in the newly created environment first solved the issue for me:

pip install --upgrade pip
陌路终见情 2025-01-25 06:59:05

只需安装依赖项:

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

源: https://doc.rust-lang .org/cargo/started/installation.html

Simply install the dependency:

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

Source: https://doc.rust-lang.org/cargo/getting-started/installation.html

叹沉浮 2025-01-25 06:59:05

我遇到了类似的问题,安装了64位版本的Python,一切正常。

I faced the similar problem, and after installing the 64-bit version of Python everything is working fine.

魔法唧唧 2025-01-25 06:59:05
  1. 安装 rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. 导出路径
export PATH="$HOME/.cargo/bin:$PATH"
  1. 源配置:Ubuntu
source ~/.profile
source ~/.cargo/env
  1. install rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. export path
export PATH="$HOME/.cargo/bin:$PATH"
  1. source config: Ubuntu
source ~/.profile
source ~/.cargo/env
oО清风挽发oО 2025-01-25 06:59:05

对于我使用的窗口
巧克力安装生锈,

如果您使用巧克力

For windows i used
choco install rust

If you use chocolaty

救星 2025-01-25 06:59:05

对于Transformers,请使用Python 3.9作品,否货物 install。

for transformers, use python 3.9 works, no cargo install.

迷你仙 2025-01-25 06:59:05

您需要使用x64本机工具命令提示vs vs 2022控制台以执行命令“ pip install open open bexter”

You need to use the x64 Native Tools Command Prompt for VS 2022 console to execute the command 'pip install open interpreter'

与往事干杯 2025-01-25 06:59:05

I already had a 64-bit version of Python (as mentioned in this other answer) but I was still facing the same problem. I upgraded pip and then everything worked fine. I did not have to install Rust.

此岸叶落 2025-01-25 06:59:05

上述错误是由生锈包造成的,

pywinpty

您需要做的就是将其从需求中删除。txt文件
并重新部署您的应用程序。

The above error is caused by a rust package

pywinpty

all you need do is to remove it from requirements.txt file
and redeploy your app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文