前言

今天升级到Python3.9发现导入不了numpy

报错信息:
RuntimeError: The current Numpy installation (‘C:\Users\Administrator\AppData\Local\Programs\Python\Python39\Lib\site-packages’) fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86

解决

到处查资料才发现是Windows系统下面Pyton3.9用不了numpy1.19.4,只需要进行降级即可

卸载:

pip uninstall numpy

安装1.19.3:

pip install numpy==1.19.3

区别

numpy1.19.4初始化代码是:

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中不存在

最后修改:2021 年 03 月 14 日
如果觉得我的文章对你有用,请随意赞赏