[英]ModuleNotFoundError: No module named 'tensorflow.keras'
[英]and ModuleNotFoundError: No module named 'tensorflow.keras'
我已经安装了 TensorFlow 和 Anaconda 但它显示错误。
我有以下版本:
Python 3.9.13
keras 2.11.0
tensorflow 2.11.0
tensorflow-estimator 2.11.0
tensorflow-gpu 2.10.1
tensorboard 2.11.0
这是我得到的错误:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow-gpu 2.10.1 requires keras<2.11,>=2.10.0, but you have keras 2.11.0 which is incompatible.
tensorflow-gpu 2.10.1 requires tensorboard<2.11,>=2.10, but you have tensorboard 2.11.0 which is incompatible.
tensorflow-gpu 2.10.1 requires tensorflow-estimator<2.11,>=2.10.0, but you have tensorflow-estimator 2.11.0 which is incompatible.
此外,我在运行时收到此错误
from tensorflow.keras.layers import TextVectorization
这是错误:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_6684\2805265792.py in <module>
----> 1 from tensorflow.keras.layers import TextVectorization
ModuleNotFoundError: No module named 'tensorflow.keras'
我尝试了以下方法:
pip install --user --upgrade tensorflow
pip install keras==2.11
pip install tensorflow-estimator==2.11
pip install tensorboard==2.11
但没有任何效果。
关于第一个错误,我认为你只需要安装兼容版本:
pip install keras==2.10.0 tensorboard==2.10 tensorflow-estimator==2.10.0
关于第二个错误,您是否尝试过:
from keras.layers import TextVectorization
而不是使用tensorflow.keras
?
(当然你pip install keras
)
好吧,我让它工作了,
所要做的就是从 Anaconda3 中删除所有tensorflow
文件和keras
`点列表'
然后使用 'pip uninstall 'file_name''
然后重新安装 tensorflow, pip install tensorflow tensorflow-gpu
第二个错误在重新安装后自行修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.