在Python 2.7中导入时出现Tensorflow错误

时间:2017-05-19 16:25:14

标签: python-2.7 tensorflow

我在MacOS上安装了Python 2.7。

我使用bazel从源代码构建了Tensorflow,如下所示:

bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

我在尝试导入Tensorflow软件包时收到以下错误。

将tensorflow导入为tf

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named pywrap_tensorflow_internal

1 个答案:

答案 0 :(得分:0)

使用pip安装后就可以了。

$ sudo pip install /tmp/tensorflow_pkg/tensorflow-1.1.0-py2-none-any.whl