在Python交互式窗口导入tensorflow出现了下面的错误:
1root@ubuntu:~# python3 2Python 3.6.8 (default, Oct 7 2019, 12:59:55) 3[GCC 8.3.0] on linux 4Type "help", "copyright", "credits" or "license" for more information. 5>>> import tensorflow as tf; 6/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:516: 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'. 7 _np_qint8 = np.dtype([("qint8", np.int8, 1)]) 8/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:517: 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'. 9 _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) 10/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:518: 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'. 11 _np_qint16 = np.dtype([("qint16", np.int16, 1)]) 12/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:519: 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'. 13 _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) 14/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:520: 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'. 15 _np_qint32 = np.dtype([("qint32", np.int32, 1)]) 16/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:525: 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'. 17 np_resource = np.dtype([("resource", np.ubyte, 1)]) 18/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: 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'. 19 _np_qint8 = np.dtype([("qint8", np.int8, 1)]) 20/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: 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'. 21 _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) 22/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: 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'. 23 _np_qint16 = np.dtype([("qint16", np.int16, 1)]) 24/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: 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'. 25 _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) 26/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: 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'. 27 _np_qint32 = np.dtype([("qint32", np.int32, 1)]) 28/usr/local/lib/python3.6/dist-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: 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'. 29 np_resource = np.dtype([("resource", np.ubyte, 1)]) 30
我的错误原因是numpy的版本较高造成的,换成1.14.0版本后解决了
出错时的Numpy版本
1root@ubuntu:~# pip3 show numpy 2Name: numpy 3Version: 1.17.3 4Summary: NumPy is the fundamental package for array computing with Python. 5Home-page: https://www.numpy.org 6Author: Travis E. Oliphant et al. 7Author-email: None 8License: BSD 9Location: /usr/local/lib/python3.6/dist-packages 10Requires:
安装1.14.0的Numpy版本
1root@ubuntu:~# pip3 install numpy==1.14.0 2Collecting numpy==1.14.0 3 Downloading https://files.pythonhosted.org/packages/dc/ac/5c270dffb864f23315e9c1f9e0a0b300c797b3c170666c031c4de42aacae/numpy-1.14.0-cp36-cp36m-manylinux1_x86_64.whl (17.2MB) 4 100% |████████████████████████████████| 17.2MB 75kB/s 5Installing collected packages: numpy 6Successfully installed numpy-1.14.0 7root@ubuntu:~# python3 8Python 3.6.8 (default, Oct 7 2019, 12:59:55) 9[GCC 8.3.0] on linux 10Type "help", "copyright", "credits" or "license" for more information. 11>>> import tensorflow as tf; 12>>> tf.__version__ 13'1.14.0' 14>>>