更新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