尝试导入tansorflow 2.0时收到“没有名为'tensorflow.python.platform'的模块”

时间:2019-11-11 20:57:21

标签: python-3.x windows tensorflow jupyter-notebook anaconda

我安装了最新的anaconda导航器1.9.7(Windows 10),并在anaconda导航器界面中创建了一个新的env(python 3.7),然后在其中安装了jupyter笔记本和tensorflow 2.0软件包。

当我尝试按以下方式导入tensorflow

import tensorflow as tf

我收到此错误

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-64156d691fe5> in <module>
----> 1 import tensorflow as tf

~\AppData\Roaming\Python\Python37\site-packages\tensorflow\__init__.py in <module>
     26 
     27 # pylint: disable=g-bad-import-order
---> 28 from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
     29 from tensorflow.python.tools import module_util as _module_util
     30 

~\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\__init__.py in <module>
     47 import numpy as np
     48 
---> 49 from tensorflow.python import pywrap_tensorflow
     50 
     51 # Protocol buffers

~\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
     23 import traceback
     24 
---> 25 from tensorflow.python.platform import self_check
     26 
     27 

ModuleNotFoundError: No module named 'tensorflow.python.platform'

我尝试使用

pip uninstall tensorflow
pip install tensorflow

和 在该目录中重命名

到目前为止没有任何效果。

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

如果您是从git克隆的,则可以

  

只需从运行configure / bazel的文件夹中更改文件夹,然后尝试将python导入tensorflow作为tf