无法在Spyder中导入TensorFlow,但可以在cmd中导入

时间:2017-12-12 16:32:28

标签: python windows tensorflow anaconda

导入TensorFlow在Spyder中完全正常工作,突然停止工作。以下是报告错误的错误。

导入tensorflow   回溯(最近一次调用最后一次):

File "<ipython-input-1-a649b509054f>", line 1, in <module>
  import tensorflow

File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
  from tensorflow.python import *

File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 100, in <module>
  from tensorflow.python.platform import app

File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 23, in <module>
  from tensorflow.python.platform import flags

File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/flags.py", line 25, in <module>
  _global_parser = _argparse.ArgumentParser()

File "/usr/lib/python2.7/argparse.py", line 1586, in __init__
  prog = _os.path.basename(_sys.argv[0])
IndexError: list index out of range

问题是什么?

1 个答案:

答案 0 :(得分:0)

当Spyder升级时,通常会出现这种问题。事实证明Spyder 3.1版本中存在一些错误,并且有一个自动升级导致导入停止工作。我刚从Anaconda Navigator降级到3.0版本,事情似乎工作正常。

This链接详细讨论了相同内容。