tensorflow AttributError:类型对象'NewBase'没有属性'is_abstract'

时间:2017-01-08 04:41:31

标签: python tensorflow

已升级六次。 pip成功安装了tensorflow。通过几个步骤/升级只是为了达到这一点。现在,当我尝试导入python时出现了这个错误。

>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Library/Python/2.7/site-packages/tensorflow/python/__init__.py", line 106, in <module>
from tensorflow.python.platform import test
File "/Library/Python/2.7/site-packages/tensorflow/python/platform/test.py", line 67, in <module>
from tensorflow.python.framework import test_util as _test_util
File "/Library/Python/2.7/site-packages/tensorflow/python/framework/test_util.py", line 43, in <module>
from tensorflow.python.platform import googletest
File "/Library/Python/2.7/site-packages/tensorflow/python/platform/googletest.py", line 32, in <module>
from tensorflow.python.platform import benchmark  # pylint: disable=unused-import
File "/Library/Python/2.7/site-packages/tensorflow/python/platform/benchmark.py", line 119, in <module>
class Benchmark(six.with_metaclass(_BenchmarkRegistrar, object)):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py", line 566, in with_metaclass
return meta("NewBase", bases, {})
File "/Library/Python/2.7/site-packages/tensorflow/python/platform/benchmark.py", line 114, in __new__
if not newclass.is_abstract():
AttributeError: type object 'NewBase' has no attribute 'is_abstract'

帮助!

4 个答案:

答案 0 :(得分:1)

那是因为你的&#34;六&#34;包已过时。请在下面进行:

  1. 通过以下方式查看您的六个版本:python;进口六;打印(6。的版本
  2. 如果版本&lt; 1.10,那么你需要升级到新版本
  3. sudo easy_install --upgrade six
  4. 再次检查六个版本,并确保版本&gt; = 1.10
  5. redo python; import tensorflow as tf;
  6. 祝你好运!

答案 1 :(得分:1)

升级六将解决问题。 TensorFlow需要six => 1.10 - 通过解释器检查六个版本:

$ python
>>>import six
>>>print six.\__version\__

或者,您只需使用pip检查它:

$ pip show six

如果您的六个版本低于1.10,请将其升级:

$ pip install --upgrade six

答案 2 :(得分:0)

可能为时已晚,但我提出了一个建议。

对于Mac OS X,Python模块可以放在两个不同的位置,这可能会导致问题。

请检查模块,六,本例,在:

  • /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
  • /Library/Python/2.7/site-packages /

如果您在文件夹/文件中找到旧版本,请将其删除。 希望这会有所帮助。

答案 3 :(得分:-1)

我遇到了类似的问题,但可能出于其他原因。我碰巧安装了一个名为rdkit的软件包(最近)。碰巧有一个更老的版本的six.py嵌入式(v1.6.1为什么 - idk?)。但是,我能够复制一个更新的six.py替换版本,并在为rdkit添加一个小修复程序之后修复了所有内容。对于我正在做的工作,遗憾的是我在同一环境中需要rdkit。我想如果您使用使用自己版本的six.py。

的软件包,则需要查找其他内容