编译好Tensorflow,import时出现“ImportError: No module named platform”错误

当经过千辛万苦通过源码编译好Tensorflow后,准备试一下,出现如下错误:

>>> import tensorflow
Traceback (most recent call last):
  File "", line 1, in 
  File "tensorflow/__init__.py", line 24, in 
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "tensorflow/python/__init__.py", line 49, in 
    from tensorflow.python import pywrap_tensorflow
  File "tensorflow/python/pywrap_tensorflow.py", line 25, in 
    from tensorflow.python.platform import self_check
ImportError: No module named platform

原因是你在Tensorflow的源码目录下执行,因为sys.path包含了当前目录,而当前目录中也包含了tensorflow/python/platform路径,换一个目录执行就没有这个问题了。

你可能感兴趣的:(编译好Tensorflow,import时出现“ImportError: No module named platform”错误)