1

I have tensorflow version 1.0.0 non-GPU version on my macbook pro Yosemite. It is installed in a virtualenv, and I have python 2.7. I have six version 1.4.1. When I do python on the command line and import six, it works fine. But when I enter 'ipython' and import tensorflow, I see this error:

AttributeError                            Traceback (most recent call last)
<ipython-input-1-cd232424f60d> in <module>()
----> 1 execfile('hw4/net.py')

/Users/lingxiao/Documents/research/dialogue-systems/hw4/net.py in <module>()
      8 import time
      9 import numpy as np
---> 10 import tensorflow as tf
     11 
     12 import app

/Users/lingxiao/tensorflow/lib/python2.7/site-packages/tensorflow/__init__.py in <module>()
     22 
     23 # pylint: disable=wildcard-import
---> 24 from tensorflow.python import *
     25 # pylint: enable=wildcard-import
     26 

/Users/lingxiao/tensorflow/lib/python2.7/site-packages/tensorflow/python/__init__.py in <module>()
    122 from tensorflow.python.platform import resource_loader
    123 from tensorflow.python.platform import sysconfig
--> 124 from tensorflow.python.platform import test
    125 
    126 from tensorflow.python.util.all_util import remove_undocumented

/Users/lingxiao/tensorflow/lib/python2.7/site-packages/tensorflow/python/platform/test.py in <module>()
     67 # pylint: disable=g-bad-import-order
     68 from tensorflow.python.client import device_lib as _device_lib
---> 69 from tensorflow.python.framework import test_util as _test_util
     70 from tensorflow.python.platform import googletest as _googletest
     71 from tensorflow.python.util.all_util import remove_undocumented

/Users/lingxiao/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/test_util.py in <module>()
     41 from tensorflow.python.framework import random_seed
     42 from tensorflow.python.framework import versions
---> 43 from tensorflow.python.platform import googletest
     44 from tensorflow.python.platform import tf_logging as logging
     45 from tensorflow.python.util import compat

/Users/lingxiao/tensorflow/lib/python2.7/site-packages/tensorflow/python/platform/googletest.py in <module>()
     31 
     32 from tensorflow.python.platform import app
---> 33 from tensorflow.python.platform import benchmark  # pylint: disable=unused-import
     34 
     35 Benchmark = benchmark.TensorFlowBenchmark  # pylint: disable=invalid-name

/Users/lingxiao/tensorflow/lib/python2.7/site-packages/tensorflow/python/platform/benchmark.py in <module>()
    115 
    116 
--> 117 class Benchmark(six.with_metaclass(_BenchmarkRegistrar, object)):
    118   """Abstract class that provides helper functions for running benchmarks.
    119 

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc in with_metaclass(meta, *bases)
    564 def with_metaclass(meta, *bases):
    565     """Create a base class with a metaclass."""
--> 566     return meta("NewBase", bases, {})
    567 
    568 def add_metaclass(metaclass):

/Users/lingxiao/tensorflow/lib/python2.7/site-packages/tensorflow/python/platform/benchmark.py in __new__(mcs, clsname, base, attrs)
    110     newclass = super(mcs, _BenchmarkRegistrar).__new__(
    111         mcs, clsname, base, attrs)
--> 112     if not newclass.is_abstract():
    113       GLOBAL_BENCHMARK_REGISTRY.add(newclass)
    114     return newclass

AttributeError: type object 'NewBase' has no attribute 'is_abstract'

I tried upgrading six and I am still seeing version 1.4.1. Is six the problem here? if not what is?

xiaolingxiao
  • 4,793
  • 5
  • 41
  • 88

2 Answers2

2

It seems that there's a number of things tangled. I'm using Anaconda2 with six==1.10.0, tensorflow==1.0.0 and Python 2.7.12. A quick experiment would be to install Anaconda2 (i.e. with python2.7) then pip install TF and other dependencies and try it out.

The Anaconda installation is self-contained, so that you won't be affected by other system-wide issues. I just did it by running /Users/myusername/anaconda2/bin/ipython

ruoho ruotsi
  • 1,283
  • 14
  • 13
1

My guess is that you need to install iPython from within the virtual environment. if you haven't done that, ipython will use the vanilla interpreter even though you are in a virtual environment.

Colin Nichols
  • 714
  • 4
  • 12
  • when I try to `pip install ipython` inside my virtualenv, it says requirements already satisfied though? – xiaolingxiao Mar 08 '17 at 22:55
  • how did you create and activate the virtual environment? what is the output of " which ipython" and "which pip"? what are the outputs of those commands when you are outside of the virtual environment? – Colin Nichols Mar 08 '17 at 23:14
  • I did `source ~/tensorflow/bin/activate`, which ipython is at `/usr/local/bin/ipython`, which pip is `/Users/lingxiao/tensorflow/bin/pip`. Outside of virtual env ipython is at `/usr/local/bin/ipython`, pip is at `/usr/local/bin/pip` – xiaolingxiao Mar 08 '17 at 23:16
  • `which ipython` should also return a path within the virtual environment, similar to pip. I would try uninstalling and reinstalling ipython from within the virtual environment. And if that doesn't work, it might be time to blow away the virtual environment and make a new one. – Colin Nichols Mar 08 '17 at 23:20
  • it's funny because which ipython inside the environment does not return a path from within, it's at usr/local/bin/ipython. When I try to uninstall it from inside the virtualenv, I get `Not uninstalling ipython at /Library/Python/2.7/site-packages, outside environment /Users/lingxiao/tensorflow` – xiaolingxiao Mar 08 '17 at 23:42
  • I would remove the virtual environment, make sure the virtualenv package is up to date, and remake the virtual environment. – Colin Nichols Mar 09 '17 at 00:27