原文链接:http://www.juzicode.com/archives/2681
错误提示:
numpy模块(v1.19.4)一开始使用没有问题,重启电脑后导入numpy模块时报错:fails to pass a sanity check due to a bug in the windows runtime:
在jupyter中运行提示sanity check错误:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-4-d4cdadb62aa7> in <module>
----> 1 import numpy
d:\python\python38\lib\site-packages\numpy\__init__.py in <module>
303
304 if sys.platform == "win32" and sys.maxsize > 2**32:
--> 305 _win_os_check()
306
307 del _win_os_check
d:\python\python38\lib\site-packages\numpy\__init__.py in _win_os_check()
300 "See this issue for more information: "
301 "https://tinyurl.com/y3dm3h86")
--> 302 raise RuntimeError(msg.format(__file__)) from None
303
304 if sys.platform == "win32" and sys.maxsize > 2**32:
RuntimeError: The current Numpy installation ('d:\\python\\python38\\lib\\site-packages\\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
直接在命令行中运行python,导入numpy,也是报 sanity check 错误:
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
** On entry to DGEBAL parameter number 3 had an illegal value
** On entry to DGEHRD parameter number 2 had an illegal value
** On entry to DORGHR DORGQR parameter number 2 had an illegal value
** On entry to DHSEQR parameter number 4 had an illegal value
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python\Python38\lib\site-packages\numpy\__init__.py", line 305, in <module>
_win_os_check()
File "D:\Python\Python38\lib\site-packages\numpy\__init__.py", line 302, in _win_os_check
raise RuntimeError(msg.format(__file__)) from None
RuntimeError: The current Numpy installation ('D:\\Python\\Python38\\lib\\site-packages\\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
错误原因:
1、win10系统更新升级到2004版本后,导致numpy不能使用,numpy版本和windows版本不兼容导致。
解决方法:
1、尝试回退numpy版本,先卸载1.19.4:
pip uninstall numpy
Uninstalling numpy-1.19.4:
Would remove:
d:\python\python38\lib\site-packages\numpy-1.19.4.dist-info\*
d:\python\python38\lib\site-packages\numpy\*
d:\python\python38\scripts\f2py.exe
Proceed (y/n)? y
Successfully uninstalled numpy-1.19.4
ERROR: Exception:
Traceback (most recent call last):
File "d:\python\python38\lib\shutil.py", line 613, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] 拒绝访问。: 'D:\\Python\\Python38\\Lib\\site-packages\\~umpy\\.libs\\libopenblas.NOIJJG62EMASZI6NYURL6JBKM4EVBGM7.gfortran-win_amd64.dll
在卸载numpy版本时发生异常,提示dll错误,不用理会,再安装v1.19.3:
E:\juzicode>pip install numpy==1.19.3 -i https://pypi.douban.com/simple/
Looking in indexes: https://pypi.douban.com/simple/
Collecting numpy==1.19.3
Downloading https://pypi.doubanio.com/packages/a4/23/13d2991c156cfd22bfd4a9ae6dcb1a9372004a0e16508b680d17f3280eb4/numpy-1.19.3-cp38-cp38-win_amd64.whl (13.3MB)
|████████████████████████████████| 13.3MB 6.4MB/s
Installing collected packages: numpy
Successfully installed numpy-1.19.3
再次导入numpy 模块,正常:
>>> import numpy as np
>>> np.arange(5)
array([0, 1, 2, 3, 4])
>>> np.mat('1,2,3;4,5,6;7,8,9')
matrix([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
>>>
关注微信公众号:“桔子code”,欢迎后台留言撩我,我会尽我所能为你解惑Python,C等编程知识