Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/__init__.py", line 4, in <module>
from keras.api import DTypePolicy
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/api/__init__.py", line 7, in <module>
from keras.api import _tf_keras
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/api/_tf_keras/__init__.py", line 1, in <module>
from keras.api._tf_keras import keras
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/api/_tf_keras/keras/__init__.py", line 7, in <module>
from keras.api import activations
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/api/activations/__init__.py", line 7, in <module>
from keras.src.activations import deserialize
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/__init__.py", line 1, in <module>
from keras.src import activations
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/activations/__init__.py", line 3, in <module>
from keras.src.activations.activations import elu
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/activations/activations.py", line 1, in <module>
from keras.src import backend
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/backend/__init__.py", line 9, in <module>
from keras.src.backend.common.dtypes import result_type
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/backend/common/__init__.py", line 2, in <module>
from keras.src.backend.common.dtypes import result_type
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/backend/common/dtypes.py", line 5, in <module>
from keras.src.backend.common.variables import standardize_dtype
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/backend/common/variables.py", line 11, in <module>
from keras.src.utils.module_utils import tensorflow as tf
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/utils/__init__.py", line 1, in <module>
from keras.src.utils.audio_dataset_utils import audio_dataset_from_directory
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/utils/audio_dataset_utils.py", line 4, in <module>
from keras.src.utils import dataset_utils
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/utils/dataset_utils.py", line 9, in <module>
from keras.src import tree
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/tree/__init__.py", line 1, in <module>
from keras.src.tree.tree_api import assert_same_structure
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/tree/tree_api.py", line 6, in <module>
from keras.src.tree import optree_impl as tree_impl
File "/Users/ice/miniconda3/lib/python3.10/site-packages/keras/src/tree/optree_impl.py", line 17, in <module>
from tensorflow.python.trackable.data_structures import ListWrapper
File "/Users/ice/miniconda3/lib/python3.10/site-packages/tensorflow/python/trackable/data_structures.py", line 26, in <module>
from tensorflow.python.eager import def_function
ImportError: cannot import name 'def_function' from 'tensorflow.python.eager' (unknown location)
我尝试安装 keras,即使重新安装 TensorFlow 后也遇到同样的问题。多次尝试重新安装,但同样的问题仍然存在。尝试询问 chatgpt 但无济于事。有人遇到过这个问题吗?请发送帮助!
你解决了吗?如果是的话,你会分享答案吗?