~~557
2021-09-10 14:14
采纳率: 75%
浏览 70
已结题

运行keras报错 No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package



```python
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM

报错如下:
Using TensorFlow backend.
2021-09-10 14:09:21.164846: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
Traceback (most recent call last):
  File "D:/PyCharm/projects/LSTM.py", line 5, in <module>
    from keras.models import Sequential
  File "D:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\keras\__init__.py", line 3, in <module>
    from . import utils
  File "D:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
    from . import conv_utils
  File "D:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
    from .. import backend as K
  File "D:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\keras\backend\__init__.py", line 1, in <module>
    from .load_backend import epsilon
  File "D:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\keras\backend\load_backend.py", line 90, in <module>
    from .tensorflow_backend import *
  File "D:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
    import tensorflow as tf
  File "D:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
    from tensorflow_core import *
  File "D:\ProgramData\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
    from tensorflow.python.tools import module_util as _module_util
ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package
看网上的很多解决办法,没有解决,怕卸载tensorflow之后安装不上,之前费了好大的劲才装上
安装的版本如下:

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/652345452136112.jpg "=600 #left")
  • 收藏

2条回答 默认 最新

  • 已采纳

    降低或升级tensorflow的版本试试,另外检查一下你这个文件名是不是tensorflow.

    已采纳该答案
    打赏 评论
  • CSDN专家-HGJ 2021-09-10 14:41

    估计是tensorflow版本太低了,与keras不兼容导致的,尝试升级tensorflow版本试试,也可在github可以找到各种wheel下载。

    打赏 评论

相关推荐 更多相似问题