Hello team,
I am getting this error after I execute import tensorflow as tf.
AttributeError Traceback (most recent call last)
Cell In[1], line 1
----> 1 import tensorflow.compat.v1 as tf
2 tf.disable_v2_behavior()
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\tensorflow_init_.py:469
467 if hasattr(_current_module, “keras”):
468 try:
→ 469 _keras._load()
470 except ImportError:
471 pass
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\tensorflow\python\util\lazy_loader.py:41, in LazyLoader._load(self)
39 “”“Load the module and insert it into the parent’s globals.”“”
40 # Import the target module and insert it into the parent’s namespace
—> 41 module = importlib.import_module(self.name)
42 self._parent_module_globals[self._local_name] = module
44 # Emit a warning if one was specified
File ~\anaconda3\envs\py3-TF2.0\lib\importlib_init_.py:126, in import_module(name, package)
124 break
125 level += 1
→ 126 return _bootstrap._gcd_import(name[level:], package, level)
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras_init_.py:20
1 # Copyright 2015 The TensorFlow Authors. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the “License”);
(…)
13 # limitations under the License.
14 # ==============================================================================
15 “”“Implementation of the Keras API, the high-level API of TensorFlow.
16
17 Detailed documentation and user guides are available at
18 keras.io.
19 “””
—> 20 from keras import distribute
21 from keras import models
22 from keras.engine.input_layer import Input
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras\distribute_init_.py:18
1 # Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the “License”);
(…)
13 # limitations under the License.
14 # ==============================================================================
15 “”“Keras’ Distribution Strategy library.”“”
—> 18 from keras.distribute import sidecar_evaluator
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras\distribute\sidecar_evaluator.py:22
20 from tensorflow.python.platform import tf_logging as logging
21 from tensorflow.python.util import deprecation
—> 22 from keras.optimizers.optimizer_experimental import (
23 optimizer as optimizer_experimental,
24 )
25 from tensorflow.python.util.tf_export import keras_export
27 _PRINT_EVAL_STEP_EVERY_SEC = 60.0
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras\optimizers_init_.py:25
22 import tensorflow.compat.v2 as tf
24 # Imports needed for deserialization.
—> 25 from keras import backend
26 from keras.optimizers.legacy import adadelta as adadelta_legacy
27 from keras.optimizers.legacy import adagrad as adagrad_legacy
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras\backend_init_.py:3
1 “”“AUTOGENERATED. DO NOT EDIT.”“”
----> 3 from keras.backend import experimental
4 from keras.src.backend import abs
5 from keras.src.backend import all
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras\backend\experimental_init_.py:3
1 “”“AUTOGENERATED. DO NOT EDIT.”“”
----> 3 from keras.src.backend import disable_tf_random_generator
4 from keras.src.backend import enable_tf_random_generator
5 from keras.src.backend import is_tf_random_generator_enabled
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras\src_init_.py:21
15 “”“Implementation of the Keras API, the high-level API of TensorFlow.
16
17 Detailed documentation and user guides are available at
18 keras.io.
19 “””
20 from keras.src import distribute
—> 21 from keras.src import models
22 from keras.src.engine.input_layer import Input
23 from keras.src.engine.sequential import Sequential
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras\src\models_init_.py:18
1 # Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the “License”);
(…)
13 # limitations under the License.
14 # ==============================================================================
15 “”“Keras models API.”“”
—> 18 from keras.src.engine.functional import Functional
19 from keras.src.engine.sequential import Sequential
20 from keras.src.engine.training import Model
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras\src\engine\functional.py:33
31 from keras.src.engine import input_spec
32 from keras.src.engine import node as node_module
—> 33 from keras.src.engine import training as training_lib
34 from keras.src.engine import training_utils
35 from keras.src.saving import serialization_lib
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras\src\engine\training.py:41
39 from keras.src.optimizers import optimizer_v1
40 from keras.src.saving import pickle_utils
—> 41 from keras.src.saving import saving_api
42 from keras.src.saving import saving_lib
43 from keras.src.saving import serialization_lib
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras\src\saving\saving_api.py:25
22 from tensorflow.python.util.tf_export import keras_export
24 from keras.src.saving import saving_lib
—> 25 from keras.src.saving.legacy import save as legacy_sm_saving_lib
26 from keras.src.utils import io_utils
28 try:
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras\src\saving\legacy\save.py:27
25 from keras.src.saving.legacy import serialization
26 from keras.src.saving.legacy.saved_model import load as saved_model_load
—> 27 from keras.src.saving.legacy.saved_model import load_context
28 from keras.src.saving.legacy.saved_model import save as saved_model_save
29 from keras.src.saving.legacy.saved_model.utils import keras_option_scope
File ~\anaconda3\envs\py3-TF2.0\lib\site-packages\keras\src\saving\legacy\saved_model\load_context.py:68
64 “”“Returns whether under a load context.”“”
65 return _load_context.in_load_context()
—> 68 tf.internal.register_load_context_function(in_load_context)
AttributeError: module ‘tensorflow.compat.v2.internal’ has no attribute ‘register_load_context_function’