Install & Compatibility
Where this runs
tested against v0.26.0.dev20260614 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
build_error
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 7.2s · import 0.001s · 138MB
144MB installed
● package 144MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
tfp
✓ import tensorflow_probability as tfp
tfd
✓ import tensorflow_probability.distributions as tfd
tfb
✓ import tensorflow_probability.bijectors as tfb
tf
✓ import tensorflow as tf
This quickstart demonstrates how to create a basic Normal distribution, sample from it, calculate log probabilities, and apply a bijector to transform it into a LogNormal distribution. It showcases the core `distributions` and `bijectors` modules of TensorFlow Probability.
import tensorflow as tf
import tensorflow_probability as tfp
tfd = tfp.distributions
tfb = tfp.bijectors
# Create a Normal distribution
mean = tf.constant(0.0, dtype=tf.float32)
stddev = tf.constant(1.0, dtype=tf.float32)
normal_dist = tfd.Normal(loc=mean, scale=stddev)
# Sample from the distribution
samples = normal_dist.sample(10)
print("Samples from Normal distribution:", samples)
# Calculate log probability
log_prob = normal_dist.log_prob(0.5)
print("Log probability of 0.5:", log_prob)
# Demonstrate a bijector (e.g., Exp) to create a LogNormal distribution
exp_bijector = tfb.Exp()
log_normal_dist = exp_bijector(normal_dist)
# Sample from the transformed distribution
log_normal_samples = log_normal_dist.sample(5)
print("Samples from LogNormal distribution (via Exp bijector):", log_normal_samples)
Debug
Known issues
breakingTensorFlow Probability currently relies on Keras 2 for its Keras backend integration. With TensorFlow 2.16+ (including `tensorflow-nightly`), `tf.keras` now points to Keras 3. This leads to incompatibility issues.fixYou must explicitly install `tf-keras` (or `tf-keras-nightly`) and ensure your `tfp-nightly` setup utilizes it instead of `tf.keras`. Some examples might involve `import tf_keras as keras` and configuring TFP to use this module.
affects: 0.24.0 and later (and corresponding `tfp-nightly` builds)
breakingSupport for Python 3.8 has been officially removed from TensorFlow Probability.fixUpgrade your Python environment to version 3.9 or higher (e.g., 3.9, 3.10, 3.11).
affects: 0.22.0 and later (and corresponding `tfp-nightly` builds)
gotcha`tfp-nightly` is built and tested against `tensorflow-nightly` and specific JAX versions. Using `tfp-nightly` with stable TensorFlow releases or significantly older/newer `jax` versions can lead to runtime errors or unexpected behavior due to API mismatches.fixAlways install `tensorflow-nightly` alongside `tfp-nightly` to maintain compatibility, e.g., `pip install --upgrade tensorflow-nightly tfp-nightly`. Consult TFP release notes for recommended JAX versions.
affects: All `tfp-nightly` versions
gotchaAs a nightly build, `tfp-nightly` may introduce API changes, experimental features, or deprecations without strict backward compatibility guarantees. Code written for stable `tensorflow-probability` might break with `tfp-nightly`.fixBe prepared for frequent updates and potential API churn. Review GitHub pull requests, issues, and release notes for changes. Use `tfp-nightly` primarily for testing new features or contributing, and `tensorflow-probability` for production workloads.
affects: All `tfp-nightly` versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'tensorflow_probability.python.internal.backend.keras'
TensorFlow 2.16+ uses Keras 3, but TFP expects Keras 2. The Keras 2 backend module cannot be found at the expected path.
fixInstall `tf-keras` (or `tf-keras-nightly`) using `pip install tf-keras`. You may also need to explicitly configure TFP to use this Keras version if issues persist.
ValueError: Python 3.8 is no longer supported by TensorFlow Probability.
Attempting to install or run `tfp-nightly` on an unsupported Python 3.8 environment.
fixUpgrade your Python environment to 3.9, 3.10, or 3.11.
AttributeError: module 'tensorflow.python.framework.ops' has no attribute 'uid'
This error typically indicates an incompatibility between the installed `tfp-nightly` and `tensorflow-nightly` versions, where one expects an API that the other no longer provides or has changed.
fixEnsure both `tensorflow-nightly` and `tfp-nightly` are updated to their very latest versions: `pip install --upgrade tensorflow-nightly tfp-nightly`.
TypeError: 'int' object is not iterable
This can occur due to subtle API changes in nightly builds, especially concerning how shapes, dtypes, or specific arguments are handled in distributions or bijectors. It might also relate to NumPy deprecation warnings and changes in array casting.
fixCheck the latest `tfp-nightly` release notes or GitHub issues. Ensure all input tensors have explicit shapes and correct dtypes. For instance, ensure single-element tensors are not implicitly cast to Python integers when iterating is expected.
Upgrade
Version history
0.26.0.dev20260614latest on PyPI · released Jun 14, 2026
Audit
Dependencies
tensorflow-nightlyrequiredtfp-nightly is built against and requires a compatible version of TensorFlow's nightly build for optimal compatibility and performance.
tf-kerasrequiredWith TensorFlow 2.16+, `tf.keras` refers to Keras 3. TFP currently relies on Keras 2, which is now packaged as `tf-keras` (or `tf-keras-nightly`). This dependency is crucial for using TFP with recent TensorFlow versions.
jaxoptionalTFP supports JAX as an alternative backend for numerical computation and is tested against specific JAX versions.