Skip to main content
 首页 » 编程设计

Python 错误 : "ImportError: cannot import name isnat"

2025年05月04日21kerrycode

Python 抛出以下错误:

File "C:\Python27\Lib\site-packages\numpy\core\arrayprint.py", line 42 
    from .umath import absolute, not_equal, isnan, isinf, isfinite, isnat    
ImportError: cannot import name isnat 

这很奇怪,因为我找不到isnat 文档。我的 numpy 版本是 1.14.0,这似乎是唯一无法从 .umath 加载的库。

请您参考如下方法:

我有同样的问题,同样使用来自 https://stackoverflow.com/a/40366276/1283083 的命令重新安装没有帮助。

但是,我能够通过以管理员身份从命令提示符运行以下命令来导入 numpy:

pip install -U --force-reinstall numpy 

不确定为什么会起作用,但现在我的 IDE 中加载了 numpy。我从 https://github.com/dwhswenson/contact_map/blob/master/docs/installing.rst 得到命令