Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Getting error "A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.1 as it may crash" in 4.12.0.88

未关闭
#1,149 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
numpy, python

调研方向

从链接的 opencv-install-failure-repro 复现开始,使用 NumPy 2.x 和软件包版本 4.12.0.88 运行 uv run main.py。跟踪 import cv2 的失败,以及所涉及的生成 wheel 或 build 配置。完成标准是:报告的复现能够在 NumPy 2.x 下成功导入 cv2,且不需要降级到 NumPy 1.x。

由索引模型根据 Issue 内容生成。

描述

I am trying to install the latest version (4.12.0.88) with numpy 2.x but I get the following error saying the module is not compiled with 1.x.
If I understand correctly, 4.12.0.88 supports numpy 2.x. Can someone give my advice on how I can fix this issue without downgrading numpy to 1.x?

Reproduction code

$ uv run main.py

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "/home/pi/developer/opencv-install-failure-repro/main.py", line 1, in <module>
    import cv2
  File "/home/pi/developer/opencv-install-failure-repro/.venv/lib/python3.11/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/home/pi/developer/opencv-install-failure-repro/.venv/lib/python3.11/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
AttributeError: _ARRAY_API not found
Traceback (most recent call last):
  File "/home/pi/developer/opencv-install-failure-repro/main.py", line 1, in <module>
    import cv2
  File "/home/pi/developer/opencv-install-failure-repro/.venv/lib/python3.11/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/home/pi/developer/opencv-install-failure-repro/.venv/lib/python3.11/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: numpy.core.multiarray failed to import
主要语言
Python
星标
5.4k
派生
1k
平均合并
22 小时 17 分钟
30 天内合并 PR
3

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

opencv/opencv-python 的其他 Issue

查看 opencv/opencv-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。