【Tensorflow】更新后报错 numpy.core.umath

更新tf后import tensorflow报错
ImportError: numpy.core.umath failed to import
这里记录了一种解决思路

解决方法

首先先确定自己安装的tensorflow与numpy版本:

pip list
>>> tensorflow   1.13.1
>>>numpy         1.13.0 

随后到github上查询tensorflow版本需要的numpy版本:

REQUIRED_PACKAGES = [
    'absl-py >= 0.7.0',
    'astor >= 0.6.0',
    'gast >= 0.2.0',
    'google_pasta >= 0.1.2',
    'keras_applications >= 1.0.6',
    'keras_preprocessing >= 1.0.5',
    'numpy >= 1.14.5, < 2.0',
    'six >= 1.10.0',
    'protobuf >= 3.6.1',
    'tensorboard >= 1.13.0, < 1.14.0',
    'tensorflow_estimator >= 1.13.0rc0, < 1.14.0rc0',
    'termcolor >= 1.1.0',
    'wrapt >= 1.11.1',
]

发现numpy需要大于1.14.5,所以重新安装numpy>=1.14.5
pip install numpy==1.16.0 注:需要针对自己的tf版本来选定需要安装版本
再次导入import tensorflow解决问题。


针对不同的tensorflow版本可以按照这个思路排错。

import tensorflow时出现numpy问题,大概率是tf与np的版本不兼容(如果有GPU/nv error,还有大概率是nv相关包没安装好),所以在安装/更新tensorflow时,需要check一下setup里面的require,同时确认需要的驱动,runtime,各种库路径是否配置正确。

ref:
https://stackoverflow.com/questions/48477909/tensorflow-import-error
https://stackoverflow.com/questions/54066132/tensorflow-importerror-dll-load-failed
https://blog.csdn.net/jiangsujiangjiang/article/details/89329527
https://www.cnblogs.com/AlvinSui/p/8668918.html
https://github.com/tensorflow/tensorflow/issues/25636
https://github.com/numpy/numpy/issues/11871
https://github.com/numpy/numpy/pull/10915

在这里插入图片描述

原文地址:https://www.cnblogs.com/Tom-Ren/p/11054621.html