AttributeError module 'tensorflow.python.training.checkpointable' has no attribute 'CheckpointableBase'
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
The error AttributeError: module 'tensorflow.python.training.checkpointable' has no attribute 'CheckpointableBase' occurs because CheckpointableBase was renamed to Trackable in TensorFlow 2.x. Code written for TF 1.x (or libraries depending on TF 1.x internals) references the old internal API path. The fix is to upgrade TensorFlow and the library that triggered the error, or pin compatible versions if you must stay on TF 1.x.
The Error
This typically appears when:
- You upgraded TensorFlow but a dependent library still uses old internal APIs
- You are running code written for TF 1.x on TF 2.x
- A third-party library (keras-contrib, tensorflow-addons old versions, etc.) references removed internals
What Changed
TensorFlow reorganized its internal checkpoint/tracking API across versions:
| TF Version | API Path | Class Name |
| TF 1.x (early) | tf.python.training.checkpointable | CheckpointableBase |
| TF 1.15 | tf.python.training.tracking | TrackableBase |
| TF 2.x | tf.python.training.tracking | AutoTrackable |
Fix 1: Upgrade Everything (Recommended)
Most libraries have updated to use TF 2.x APIs. Upgrading resolves the issue.
Fix 2: Pin Compatible Versions
If you must use older code:
Fix 3: Monkey-Patch (Temporary Workaround)
This is a temporary fix — update the actual code or library as soon as possible.
Fix 4: Update the Import in Your Code
If the error is in your own code:
In most cases, you should use tf.keras.layers.Layer or tf.Module instead of internal tracking classes.
Fix 5: Use tf.compat.v1 for Migration
tf.compat.v1 does not restore all internal API paths. It primarily restores the public API (sessions, placeholders, etc.).
Identifying the Source
This helps identify which package needs upgrading.
Common Packages That Cause This
| Package | Fix |
keras-contrib | Upgrade or switch to tensorflow-addons |
tf-slim | pip install tf-slim>=1.1.0 |
tensorflow-addons | pip install tensorflow-addons>=0.15.0 |
tensorflow-hub | pip install tensorflow-hub>=0.12.0 |
| Custom code | Update imports to use tf.Module or tf.keras.layers.Layer |
Version Checking
Common Pitfalls
- Mixing TF 1.x and 2.x packages: Installing
tensorflow==2.xwith a library built fortensorflow==1.xcauses this error. Check compatibility matrices for all ML packages. - Using internal APIs:
tensorflow.python.*paths are internal and not guaranteed to be stable. Use public APIs (tf.keras,tf.Module,tf.saved_model) which have stability guarantees. - Virtual environment confusion: You may have TF 2.x installed globally but TF 1.x in a virtualenv (or vice versa). Check
pip list | grep tensorflowin the active environment. - Cached .pyc files: Old compiled Python files may reference the removed module. Delete
__pycache__directories and.pycfiles after upgrading. - Docker/container images: Pre-built Docker images (e.g.,
tensorflow/tensorflow:1.x) have old TF versions. Update your Dockerfile to usetensorflow/tensorflow:latestor a specific 2.x tag.
Summary
CheckpointableBasewas renamed toTrackablein TensorFlow 2.x- The error occurs when old code or libraries reference
tensorflow.python.training.checkpointable - Fix by upgrading TensorFlow and all dependent ML libraries to compatible versions
- Use
tf.keras.layers.Layerortf.Moduleinstead of internal tracking classes - Avoid importing from
tensorflow.python.*paths — they are internal and change between versions - Use
grepto find which installed package makes the outdated import
Related reading
- AttributeError 'str' object has no attribute 'decode' while Loading a Keras Saved Model
- AttributeError 'Tensor' object has no attribute 'numpy
- AttributeError 'Tensor' object has no attribute 'numpy' in Tensorflow 2.1
- AttributeError The layer has never been called and thus has no defined input shape
- AttributeError 'Node' object has no attribute 'output_masks
- AttributeError 'NoneType' object has no attribute 'fit_generator
- AttributeError 'SMOTE' object has no attribute 'fit_sample
- AttributeError The layer has never been called and thus has no defined output shape
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.