python numpy版本报错: File "*\numpy\__init__.py", line 305, in <module> _win_os_check()
具体代码如下所示:
from numpy import * import operator a = random.rand(4, 4) print(a)
具体报错内容如下所示:
Traceback (most recent call last): File "D:/py_prj/rtl_split/venv/Include/test.py", line 1, in <module> from numpy import * File "*\numpy\__init__.py", line 305, in <module> _win_os_check() File "*\numpy\__init__.py", line 302, in _win_os_check raise RuntimeError(msg.format(__file__)) from None RuntimeError: The current Numpy installation ('*\\numpy\\__init__.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86
参考资料:https://github.com/numpy/numpy/wiki/FMod-Bug-on-Windows
There is a Bug with fmod
on windows, see https://tinyurl.com/y3dm3h86
To prevent unexpected runtime behavior, opencv contains a Check for this:
try:
a = arange(13 * 13, dtype= float64).reshape(13, 13)
a = a % 17 # calls fmod
linalg.eig(a)
except Exception:
raise RuntimeError("The current Numpy installation (...) fails to pass a sanity check due to a bug in the windows runtime. ...
See Pull Request https://github.com/numpy/numpy/pull/17553
Workaround
This is a windows issue and has to be fixed by Microsoft, however, a fix has not arrived for several weeks now.
-
Pinning against NumPy 1.19.3 should help (it uses a newer OpenBLAS version, but this caused other problems). This can be achieved using e.g. with
pip install numpy==1.19.3
or similar depending on your setup. To be clear: The only difference between NumPy 1.19.3 and 1.19.4 is the OpenBLAS version it ships. -
32bit Python does not have these issues
-
In principle you could revert the buggy windows update or deactivate the
_win_os_check
in NumPy (if you are lucky, your code is unaffected by the bug).
原因:是1.19.4版本有问题,需要安装1.19.3版本
更换版本后使用 import numpy
numpy.__version__ 可以查看该版本号
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)