如何使用Tensorflow修复此错误?

时间:2019-09-01 07:33:56

标签: python tensorflow python-3.7

我对使用Python进行编码非常陌生,在我要学习的教程中,我必须安装Tensorflow。但是,当我将Tensorflow导入我的python(2.6)时,我收到一条错误消息。在开始实际编码之前,我想修复此错误。

我已经尝试了4天,以消除Miniconda3中Tensorflow的错误。我已经尝试安装Tensorflow的特定版本,但运气很好:pip install tensorflow。如果我在命令提示符或PyCharm中,也会遇到相同的错误。

这是我每次输入都会得到错误消息的内容:

import tensorflow

在我观看的视频中,这不是应该发生的事情,至少在PyCharm中应该发生的消息是:

进程退出代码为0

以下是确切的错误消息:

C:\Users\StRUT\Miniconda3\envs\tensorflow2\lib\site-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'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\StRUT\Miniconda3\envs\tensorflow2\lib\site-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'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Users\StRUT\Miniconda3\envs\tensorflow2\lib\site-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'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\StRUT\Miniconda3\envs\tensorflow2\lib\site-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'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Users\StRUT\Miniconda3\envs\tensorflow2\lib\site-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'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Users\StRUT\Miniconda3\envs\tensorflow2\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_resource = np.dtype([("resource", np.ubyte, 1)])
C:\Users\StRUT\Miniconda3\envs\tensorflow2\lib\site-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'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\StRUT\Miniconda3\envs\tensorflow2\lib\site-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'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Users\StRUT\Miniconda3\envs\tensorflow2\lib\site-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'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\StRUT\Miniconda3\envs\tensorflow2\lib\site-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'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Users\StRUT\Miniconda3\envs\tensorflow2\lib\site-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'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Users\StRUT\Miniconda3\envs\tensorflow2\lib\site-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'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])

我希望我能给你们足够的信息来帮助我,因为我真的很想开始学习使用干净的python代码。

预先感谢, 布莱克

3 个答案:

答案 0 :(得分:0)

这些不是错误消息,而是有关numpy中已弃用功能的警告,该警告已由tensorboard和ten​​sorflow使用。警告不是错误,因此不必担心。

“修复”警告的唯一方法是等待tensorflow开发人员修改代码,以不使用不推荐使用的功能。

答案 1 :(得分:0)

这些只是警告,TensorFlow正在使用一些很快将不可用的东西,如果您想抑制它,则可以使用以下命令运行文件

python -W忽略filename.py

答案 2 :(得分:0)

我通过以下方式解决了警告问题:

pip install --upgrade numpy==1.16.4

警告完全消失并且问题已解决。感谢您的帮助!