2016-12-07 186 views
5

我試圖在TensorFlow install docs之後在Mac上設置TensorFlow。TensorFlow導入錯誤:沒有名爲_pywrap_tensorflow的模塊

但是完成概述的步驟和努力後,「import tensorflow as tf」,我得到了下面的錯誤跟蹤:

>>> import tensorflow as tf 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module> 
    from tensorflow.python import * 
    File "/usr/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module> 
    from tensorflow.python import pywrap_tensorflow 
    File "/usr/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 21, in <module> 
    _pywrap_tensorflow = swig_import_helper() 
    File "/usr/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 20, in swig_import_helper 
    return importlib.import_module('_pywrap_tensorflow') 
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
ImportError: No module named _pywrap_tensorflow 

我已經安裝並使用過TensorFlow我的機器上,從來沒有遇到過這個問題。

回答

2

這部分看起來錯誤:

File "/usr/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 20, in swig_import_helper 
    return importlib.import_module('_pywrap_tensorflow') 
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 

它使用pywrap_tensorflow從Python安裝在/usr/local/lib/python2.7importlib從一個在/usr/local/Cellar/python/2.7.9

你的Python包搜索路徑一定有問題。見例如Keras import error Nadam有關故障排除提示。

相關問題