和 ModuleNotFoundError:没有名为"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)
~AppDataLocalTempipykernel_66842805265792.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?

(当然你必须先安装keras和pip install keras)

如果它成功了,

只需要从Anaconda3中删除所有tensorflow文件和keras文件

  1. "皮普列表">

  2. 然后使用'pip uninstall 'file_name "

  3. 然后重新安装tensorflow,pip install tensorflow tensorflow-gpu

第二个错误在重新安装后自行修复。

相关内容

  • 没有找到相关文章

最新更新