TensorFlow安装完成之后,在import tensorflow(1.9版本)时出现下面的情况:
>>> import tensorflow
C:\Users\AndyG\.conda\envs\tf_1\lib\site-packages\tensorflow\python\framework\dtypes.py:523: 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_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\AndyG\.conda\envs\tf_1\lib\site-packages\tensorflow\python\framework\dtypes.py:524: 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)])
C:\Users\AndyG\.conda\envs\tf_1\lib\site-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'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\AndyG\.conda\envs\tf_1\lib\site-packages\tensorflow\python\framework\dtypes.py:526: 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_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Users\AndyG\.conda\envs\tf_1\lib\site-packages\tensorflow\python\framework\dtypes.py:527: 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_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Users\AndyG\.conda\envs\tf_1\lib\site-packages\tensorflow\python\framework\dtypes.py:532: 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_resource = np.dtype([("resource", np.ubyte, 1)])
从提示中看出,是numpy版本过高导致的,所以我先看了下numpy 的版本:
>>> import numpy
>>> numpy.__version__
'1.17.4'
于是我退出python命令窗口,回到Windows命令提示符窗口:
输入pip install numpy==1.16
(tf_1) C:\Users\AndyG>pip install numpy==1.16
Collecting numpy==1.16
Downloading https://files.pythonhosted.org/packages/31/7e/8905636f7e4f9b9d7078aa0e701500634f832f145855a11beb098d3b0fb1/numpy-1.16.0-cp36-cp36m-win_amd64.whl (11.9MB)
|████████████████████████████████| 11.9MB 3.2MB/s
Installing collected packages: numpy
Found existing installation: numpy 1.17.4
Uninstalling numpy-1.17.4:
Successfully uninstalled numpy-1.17.4
Successfully installed numpy-1.16.0
可以看到,1.17版本自动卸载,并成功安装了1.16版本。
再次启动python,导入TensorFlow:
(tf_1) C:\Users\AndyG>python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>>
完成!