如何修复 numpy 和 Pandas 的“ runtimeError: package 未能通过健全检查”?

这就是我得到的错误,就我所知,在错误链接上没有任何有用的东西来修复这个错误。

RuntimeError: 当前 Numpy 安装 ('...\\venv\\lib\\site-packages\\numpy\\__init__.py')未能通过 由于 Windows 运行时中的错误而进行的健全性检查。

有关更多信息,请参见此问题: https://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html

我已经尝试了多个版本的 Python (3.8.6和3.9.0)和 numpy 以及 Pandas。我目前正在使用 PyCharm 来完成所有这些工作。

84544 次浏览

只要安装 numpy==1.19.3 我用的是 python 3.9

使用 python3.9和 numpy1.19.4时发生此错误 所以卸载 numpy1.19.4和安装1.19.3是可行的。


剪辑

截至2021年1月5日麻木的版本 1.19.5出来,似乎解决了这个问题。

回滚到 numpy 1.19.3在 python 3.8.6上对我很有用

我正在使用 Python 3.7,无论如何,这里建议的解决方案帮助了我。

pip install numpy==1.19.3

实际上,通知 https://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html的链接显示了给定的解决方案。这似乎是 VisualStudio 中的一个 bug,直到今天仍然没有得到解决。

根据关于你提供的链接的讨论,一个愚蠢的开发人员回答说:

NumPy 已经发布了一个 bug 补丁1.19.3来解决这个问题 Bug 补丁破坏了 Linux 上的其他东西,所以我们不得不将补丁恢复到 Release 1.19.4,但是您仍然可以通过 pip install 安装1.19.3 Numpy = = 1.19.3.

因此,如果您需要同时适用于 Linux 和 Windows 的需求,则需要使用 PEP508:

numpy==1.19.3; platform_system == "Windows"
numpy>=1.19.4; platform_system == "linux"

这是 numpy 1.19.4的一个 bug,在所有 Python 版本中都会失败。使用以前版本的 解决的问题,所以按终端:

pip install numpy==1.19.3

为什么没有人公布1.19.3和1.19.4的区别。

有问题的 numpy init 代码是:

def _win_os_check():
"""
Quick Sanity check for Windows OS: look for fmod bug issue 16744.
"""
try:
a = arange(13 * 13, dtype= float64).reshape(13, 13)
a = a % 17  # calls fmod
linalg.eig(a)
except Exception:
msg = ("The current Numpy installation ({!r}) fails to "
"pass a sanity check due to a bug in the windows runtime. "
"See this issue for more information: "
"https://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html")
raise RuntimeError(msg.format(__file__)) from None


if sys.platform == "win32" and sys.maxsize > 2**32:
_win_os_check()


del _win_os_check

这个代码段在1.19.3中不存在; 这是唯一的区别。

解决方案在所提到的链接中提供。

开发人员 Mattip在他提出的解决方案中提到:

  1. 卸载 numpy (最有可能是1.19.4)
  2. Pip install numpy = = 1.19.3

这招对我很管用。

我的配置: OS-Win10,蟒蛇发行版,python = 3.7

我必须按照下面的步骤来修复这个错误,正如上面所有人建议的那样。

我的环境详细信息: 安装了 Python 3.9.0的 Windows 1064位

pip uninstall numpy
pip install numpy==1.19.3

我张贴我的 powershell 命令行输出供您参考(可能对某人有用)。

PS C: 用户 XXXX > pip 卸载 numpy

找到现有安装: numpy 1.19.4

卸载 numpy-1.19.4:

将删除:

c:\python39\lib\site-packages\numpy-1.19.4.dist-info\*


c:\python39\lib\site-packages\numpy\*


c:\python39\scripts\f2py.exe

继续(y/n) ? y

成功卸载 numpy-1.19.4

PS C: 用户 XXXX > pip install numpy = = 1.19.3

收集 numpy = = 1.19.3

下载 numpy-1.19.3-cp39-cp39-win _ amd64.whl (13.3 MB)

 |████████████████████████████████| 13.3 MB 6.4 MB/s

安装收集的包: numpy

成功安装 numpy-1.19.3