2017-03-08 85 views
1

我在我的macbook pro Yosemite上擁有tensorflow版本1.0.0非GPU版本。它安裝在virtualenv中,我有python 2.7。我有六個版本1.4.1。當我在命令行上輸入python並導入6時,它工作正常。但是,當我輸入「IPython的」進口tensorflow,我看到這個錯誤:無法在ipython中導入Tensorflow

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' 

我試圖升級六年我仍然看到的版本1.4.1。這裏有六個問題嗎?如果不是什麼?

+0

從這我不能告訴錯誤是什麼:錯誤信息是什麼。 – putonspectacles

+0

這只是錯誤消息的一部分。它突然切斷。 – user2357112

+0

抱歉,傢伙更新了帖子。 – chibro2

回答

2

看來有很多事情是糾結的。我使用的是Anaconda2與six==1.10.0tensorflow==1.0.0和Python 2.7.12。一個快速的實驗是安裝Anaconda2(即用python2.7),然後安裝pip install TF和其他依賴項並試用它。

Anaconda安裝是自包含的,因此您不會受到其他系統範圍問題的影響。我剛剛通過運行/Users/myusername/anaconda2/bin/ipython

1

我的猜測是你需要在虛擬環境中安裝iPython。如果你還沒有這樣做,即使你在虛擬環境中,ipython也會使用vanilla解釋器。

+0

當我嘗試'在我的virtualenv內部安裝ipython'時,它說需求已經滿足,但? – chibro2

+0

你是如何創建和激活虛擬環境的? 「哪個ipython」和「哪個pip」的輸出是什麼?當您處於虛擬環境之外時,這些命令的輸出是什麼? –

+0

我做過'source〜/ tensorflow/bin/activate',其中ipython位於'/ usr/local/bin/ipython',這個pip是'/ Users/lingxiao/tensorflow/bin/pip'。在虛擬環境以外,ipython位於'/ usr/local/bin/ipython'處,pip位於'/ usr/local/bin/pip' – chibro2