![](/img/trans.png)
[英]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.