干净安装Tensorflow后的ImportError

时间:2017-04-01 22:22:23

标签: python-3.x tensorflow ubuntu-16.04 importerror

我刚刚关注this tutorial在Ubuntu 16.04上从源代码安装Tensorflow,用于Python 3.5,在Nvidia显卡上支持完整的CUDA和GPU。安装成功。

我无法在Python会话中导入Tensorflow。

这是终端输出:

user@user:~/Downloads/tensorflow$ python3.5
Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "/home/user/Downloads/tensorflow/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named 'tensorflow.python.pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

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


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

2 个答案:

答案 0 :(得分:2)

我在这里找到了问题的原因,这是非常微不足道的,很容易被忽视。它现在也在教程中提到。

只需移动到另一个目录,即从所有下载文件的文件夹中移出,特别是存储Git存储库的位置。

我发现这个解决方案提到as a comment in a bug on Github

答案 1 :(得分:-1)

如果你在Windows上使用TF1.2.0rc2和CUDNN 6.0,那就创建一个名为cudnn64_5.dll的cudnn64_6.dll副本。