使用 pip 安装软件包时出现问题:“Cargo,Rust 软件包管理器,未安装或不在 PATH 上”
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
尝试为Rust编程语言安装工具,因为您似乎有一种使用Rust的依赖性。
对于Mac OS,我建议使用 brew 。
否则,请使用 rust安装页面的步骤。
您可以检查适当安装RUST:
完成后,一旦完成,请重新尝试安装需求文件。
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.
Otherwise use the steps from the Rust install page.
You can check that rust is installed properly with:
Once you are finished try again to pip install your requirements file.
我对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.
在新创建的环境中升级我的 pip 发行版首先解决了我的问题:
Upgrading my pip distribution in the newly created environment first solved the issue for me:
只需安装依赖项:
源: https://doc.rust-lang .org/cargo/started/installation.html
Simply install the dependency:
Source: https://doc.rust-lang.org/cargo/getting-started/installation.html
我遇到了类似的问题,安装了64位版本的Python,一切正常。
I faced the similar problem, and after installing the 64-bit version of Python everything is working fine.
对于我使用的窗口
巧克力安装生锈,
如果您使用巧克力
For windows i used
choco install rust
If you use chocolaty
对于
Transformers
,请使用Python 3.9作品,否货物
install。for
transformers
, use python 3.9 works, nocargo
install.您需要使用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'
我已经有一个64位版本的Python(如其他答案。我升级了PIP,然后一切都很好。我不必安装生锈。
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.
上述错误是由生锈包造成的,
您需要做的就是将其从需求中删除。txt文件
并重新部署您的应用程序。
The above error is caused by a rust package
all you need do is to remove it from requirements.txt file
and redeploy your app.