python - TensorFlow导入错误: no module named _pywrap_tensorflow

标签 python tensorflow

我正在尝试在 TensorFlow install docs 之后在 Mac 上设置 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,但从未遇到过这个问题。

最佳答案

这部分看起来不对:

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)

它使用 /usr/local/lib/python2.7 中的 Python 安装中的 pywrap_tensorflow 中的 importlib/usr/local/Cellar/python/2.7.9.

一定是你的Python包搜索路径有问题。参见例如Keras import error Nadam获取故障排除提示。

关于python - TensorFlow导入错误: no module named _pywrap_tensorflow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41008524/

相关文章:

python - 基于其他数据框向 Pandas 数据框添加新列

python - Tensorflow 'NoneType' 对象没有属性 'shape'

python - tensorflow ,删除重复项

tensorflow - 什么时候在 Keras Lambda 层中生成随机数?

python - pandas df.loc[z,x]=y 如何提高速度?

python - 将网格从中心坐标重新采样到外部(即角)坐标

python - 我可以指定另一个类的实例方法作为我的方法的变量吗?

python - sqlalchemy 在表上的搜索功能作为类方法?

docker - Docker容器不列出我拉出的容器吗?

python-2.7 - Tensorboard - add_summary 使我的代码崩溃