错误:构建numpy轮失败,错误:无法为安装基于pyproject.toml的项目所需的numpy构建轮。

47

我在我的项目中使用了Python Poetry (https://python-poetry.org/) 来管理依赖。

但当我运行poetry install时,它给出以下错误提示:

ERROR: Failed building wheel for numpy
  Failed to build numpy
  ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects

我已在我的笔记本电脑上安装了Python 3.9。


我使用 pip install numpy 安装了numpy 1.21.5,我甚至尝试将其降级到1.19.5。

尽管如此,我仍然遇到相同的错误。

我发现许多人在Python 3.10中遇到了ERROR: Failed building wheel for numpy 这个错误,他们通过将Python版本降级到3.9来解决它,但这对我没用。


遇到了同样的问题。你解决了吗? - Aditya Singh
@AdityaSingh 我刚刚成功地更新了最新版本的 numpy,命令如下:pip install -U numpy - Benyamin Jafari
4个回答

10
我通过以下步骤解决了这个问题:
  1. 我更新了pyproject.toml文件(该文件包含所有的库/依赖/开发依赖),将我使用pip install numpy命令安装的numpy版本添加进去。 enter image description here

  2. 运行poetry lock命令来更新poetry.lock文件(包含有关库的详细信息)。 enter image description here

  3. 再次运行poetry install命令,应该可以正常工作。

简而言之,您只需安装正确版本的numpy 点击此处检查兼容性。 然后使用pip install numpy==version安装所需版本。 例如,要安装NumPy 1.23.5版本,请使用以下命令- pip install numpy==1.23.5 如果您遇到任何问题,可以留言。 我会尽力回答。

这对我也起作用了。错误出现在numpy版本1.21.2中,但在1.22.3中没有出现。请注意,较新的numpy版本(例如1.22.3)需要Python 3.8或更高版本。我不得不更新我的pyproject.toml以尊重这一点。 - ediordna
1
这个 pyproject.toml 文件应该放在哪里?我找不到它... - Nelis
1
@Nelis,它在根目录中。 - Lakshay Rohilla

4

我在macOS上使用PyPy安装numpy时遇到了问题。

我通过首先运行brew doctor来解决此问题,它显示我的命令行工具(XCode)已过期。 然后我只需按照更新它们的说明进行操作:

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

这解决了问题。


我的配置:

  • macOS 12.2.1 Monterey
> python --version
Python 3.8.12 (9ef55f6fc369, Oct 25 2021, 05:10:01)
[PyPy 7.3.7 with GCC Apple LLVM 13.0.0 (clang-1300.0.29.3)]

需要 Xcode 来安装 numpy 吗? - IgorGanapolsky
Xcode命令行工具包括诸如make之类的命令,这些命令在Linux上可能已经默认包含了。 - undefined

0

-4

Numpy 错误已解决

Error: failed to build wheels for numpy which is required to install project.tmol

这个错误是由于过时的numpy版本引起的,只需运行以下命令:
``` MATHLAB = "m" pip install numpy ```

`

我的Python版本: Python -V=3.9

在某些情况下它不起作用,但大多数情况下都可以。

如果您正在使用venv,请尝试在venv中安装numpy。 然后运行您的代码,它将正常工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接