我已经通过pip安装了tensorflow和keras并想使用它,但是以下导入失败:
from tensorflow import keras
from tensorflow.keras.models import Sequential #This line fails
错误:
File "...AppData\Local\Programs\Python\Python39\lib\site-packages\keras\src\tree\__init__.py", line 1, in <module>
from keras.src.tree.tree_api import assert_same_structure
File ""...AppData\Local\Programs\Python\Python39\lib\site-packages\keras\src\tree\tree_api.py", line 10, in <module>
raise ImportError(
ImportError: To use Keras, you need to have `optree` installed. Install it via `pip install optree`
我检查了 opttree 是否已安装,尝试重新安装但没有成功。有人遇到这个问题吗?
版本:
我碰巧遇到了同样的问题,我的解决方案是升级 opttree 版本
pip install --upgrade optree