import tensorflow报错:FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated

遇到2次了,记录一下:
在执行含有import tensorflow as tf的代码中,报错如下:
FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'._np_quint8 = np.dtype([("quint8", np.uint8, 1)])

原因:

这是因为numpy版本过高了,降低numpy版本即可消除。
查看自己numpy版本:
打开Aanconda prompt
输入:python,进入python环境

import numpy as np
np.__version__

会打印出当前numpy版本,我的是1.17.4

解决方法:

1、找到当前numpy的安装目录,删除

import numpy as np
np.__file__

会打印出numpy的安装路径,删除
2、降低版本
一般降低1到2个版本应该可以了。

pip install numpy==1.16.0

或者 pip install -U numpy==1.16.0
如果不行,可以试下1.15.0版本。

参考:https://blog.csdn.net/bigdream123/article/details/99467316下的评论。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章