微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

运行时错误:当前的 NumPy 安装未能通过健全性检查

如何解决运行时错误:当前的 NumPy 安装未能通过健全性检查

我最近构建了一个新的 Windows 10 系统,除了我的所有 python 文件之外,几乎都是新的。我需要首先实际安装 Python,所以我做了(v. 3.9.1)。我后来在cmd中安装了numpy(pip install numpy)。我目前正在使用vscode,但我下载了pylint和python扩展,所以我认为这不是问题。我继续我的最新项目,当我去运行代码时,我收到一条错误消息,如下所示:

 ** 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 "c:\Users\sava\Desktop\Python\NumGuess\lvl1.py",line 2,in <module>
    import numpy
  File "C:\Users\sava\AppData\Local\Programs\Python\python39\lib\site-packages\numpy\__init__.py",line 305,in <module>
    _win_os_check()
  File "C:\Users\sava\AppData\Local\Programs\Python\python39\lib\site-packages\numpy\__init__.py",line 302,in _win_os_check
    raise RuntimeError(msg.format(__file__)) from None
RuntimeError: The current Numpy installation ('C:\\Users\\sava\\AppData\\Local\\Programs\\Python\\python39\\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: 

我从来没有遇到过这样的事情。我做了一些研究,但我仍然不明白如何解决这个问题。它可能与安装有关,但我可以显示代码添加一些上下文:

import random
import numpy
from numlst import numlist_1


class guessnum1():

    def get_number(self):
        number = random.choice(numlist_1)
        return number.upper()

    number = random.choice(numlist_1)
    print(input("guess your number,since this is the first level you need to choose a number between 1 and 10  "))
    if input == number:
        print("Congratulations! You got the number correct!")
    
    else:
        print("Oops,you got the number wrong you have: " + " tries " + " left")


print(str(guessnum1))

我知道我的代码并不完美,但这是我在没有任何教程的情况下做的第一个项目。如果你们中有人遇到过这个错误,或者知道如何解决这个问题,请帮助我。感谢您阅读本文,祝您节日快乐。

(编辑 1:我很确定这不是问题的实际代码,并且 numlist 来自我项目中的另一个文件,我不想放入其他文件,因为它们可能无关紧要这个问题,谢谢)

解决方法

我将代码编辑为:

import random
import numpy
# from numlst import numlist_1

numlist_1 = [random.randrange(1,50,1) for i in range(7)]

class guessnum1():

    def get_number(self):
        number = random.choice(numlist_1)
        return number.upper()

    number = random.choice(numlist_1)
    print(input("guess your number,since this is the first level you need to choose a number between 1 and 10  "))
    if input == number:
        print("Congratulations! You got the number correct!")
    
    else:
        print("Oops,you got the number wrong you have: " + " tries " + " left")


guessnum1

产生这个输出:

guess your number,since this is the first level you need to choose a number between 1 and 10  5
5
Oops,you got the number wrong you have:  tries  left

请注意,我注释掉了 from numlst import numlist_1

并且还调用了 print(str(guessnum1)) 语句之外的类。

我在 python 3.9 上使用 windows 10。 我只使用 Python 扩展名, pylint

希望对您有所帮助。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。