2017-03-08 9 views
1

Ich habe Tensorflow Version 1.0.0 nicht-GPU-Version auf meinem MacBook Pro Yosemite. Es ist in einem virtualenv installiert, und ich habe Python 2.7. Ich habe sechs Version 1.4.1. Wenn ich in der Befehlszeile python mache und sechs importiere, funktioniert es gut. Aber wenn ich ‚ipython‘ und Import tensorflow geben, sehe ich diesen Fehler:Kann Tensorflow in ipython nicht importieren

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' 

Ich habe versucht, sechs Upgrade und ich sehe nach wie vor Version 1.4.1. Ist sechs das Problem hier? wenn nicht was ist?

+0

von diesem ich kann nicht sagen, was der Fehler ist: was ist die Fehlermeldung. – putonspectacles

+0

Dies ist nur ein Teil der Fehlermeldung. Es schneidet abrupt ab. – user2357112

+0

Sorry Jungs hat den Beitrag aktualisiert. – chibro2

Antwort

2

Es scheint, dass es eine Reihe von Dingen verwirrt. Ich benutze Anaconda2 mit six==1.10.0, tensorflow==1.0.0 und Python 2.7.12. Ein schnelles Experiment wäre, Anaconda2 (d. H. Mit python2.7), dann pip install TF und andere Abhängigkeiten zu installieren und es auszuprobieren.

Die Installation von Anaconda ist in sich abgeschlossen, sodass Sie von anderen systemweiten Problemen nicht betroffen sind. Ich habe es gerade gemacht, indem ich /Users/myusername/anaconda2/bin/ipython

1

Meine Vermutung ist, dass Sie iPython aus der virtuellen Umgebung installieren müssen. Wenn Sie das nicht getan haben, verwendet ipython den Vanilla-Interpreter, obwohl Sie sich in einer virtuellen Umgebung befinden.

+0

wenn ich versuche, "pip install ipython" in meinem virtualenv, es Anforderungen erfüllt bereits obwohl? – chibro2

+0

Wie haben Sie die virtuelle Umgebung erstellt und aktiviert? Was ist die Ausgabe von "which ipython" und "which pip"? Was sind die Ausgaben dieser Befehle, wenn Sie sich außerhalb der virtuellen Umgebung befinden? –

+0

Ich habe 'source ~/tensorflow/bin/activate', welches ipython ist'/usr/local/bin/ipython', welches pip ist '/ Users/lingxiao/tensorflow/bin/pip'. Außerhalb von virtuellem env ist ipython bei '/ usr/local/bin/ipython', pip ist bei'/usr/local/bin/pip' – chibro2

Verwandte Themen