Install & Compatibility
Where this runs
tested against v0.25.2 · 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.915 runs
build_error
glibcpy 3.10–3.915 runs
installs and imports cleanly · install 14.0s · import 0.000s · 342MB
354MB installed
● package 354MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
version
✓ from mleap import version
✗ from mleap.sklearn.pipeline import MLeapPipeline
This quickstart demonstrates how to train a simple scikit-learn `LinearRegression` model, wrap it in an `MLeapPipeline`, export it to an MLeap bundle file, and then load and use it for predictions. Ensure a compatible JDK is installed and `JAVA_HOME` is configured for the runtime part of MLeap.
import pandas as pd
import numpy as np
import os
import shutil
from sklearn.linear_model import LinearRegression
from mleap.sklearn.pipeline import MLeapPipeline
from mleap.bundle import Bundle
# 1. Prepare sample data
data = {
'feature1': np.random.rand(10),
'feature2': np.random.rand(10)
}
df = pd.DataFrame(data)
target = np.random.rand(10)
# 2. Train a scikit-learn model
model_sklearn = LinearRegression()
model_sklearn.fit(df[['feature1', 'feature2']], target)
# 3. Wrap the scikit-learn model in an MLeapPipeline
mleap_pipeline = MLeapPipeline([
('lr', model_sklearn)
])
# 4. Define export path and clean up previous exports
bundle_path = "/tmp/my_linear_regression_mleap.zip"
model_name = "linear_regression_mleap_model"
if os.path.exists(bundle_path):
os.remove(bundle_path)
if os.path.exists(f"/tmp/{model_name}"):
shutil.rmtree(f"/tmp/{model_name}")
# 5. Export the MLeap pipeline to a bundle file
with Bundle().writer(mleap_pipeline, df[['feature1', 'feature2']], name=model_name) as writer:
writer.serialize_to_zip(bundle_path)
print(f"MLeap model exported to: {bundle_path}")
# 6. Load the MLeap bundle back into memory
loaded_bundle = Bundle.load_model(bundle_path)
# 7. Make predictions with the loaded model
test_data = pd.DataFrame([[0.1, 0.9]], columns=['feature1', 'feature2'])
predictions = loaded_bundle.predict(test_data)
print(f"Predictions: {predictions}")
# 8. Clean up created files (optional)
if os.path.exists(bundle_path):
os.remove(bundle_path)
if os.path.exists(f"/tmp/{model_name}"):
shutil.rmtree(f"/tmp/{model_name}")
Debug
Known issues
breakingMLeap versions often align with major upgrades of underlying platforms (Java, Spark, XGBoost, TensorFlow). For example, v0.24.0 requires Java 17, Spark 4.0.1, and XGBoost 2.0.3, a significant change from prior versions (e.g., v0.22.0 supported Spark 3.3.0). This can cause compatibility issues if your runtime environment does not match the version MLeap was built against.fixCheck MLeap's release notes for the required Java Development Kit (JDK), Apache Spark, and other library versions. Update your JVM and associated dependencies accordingly to match the MLeap version you are using.
affects: 0.24.0 onwards (from previous versions)
gotchaMLeap fundamentally relies on a Java Virtual Machine (JVM) for its runtime, and the Python API interacts with this JVM via Py4J. Common issues include not having a compatible JVM installed (e.g., Java 17 for v0.24.0) or incorrect `JAVA_HOME` / classpath configuration, leading to `NoClassDefFoundError`, `JVM not found`, or `Py4JError` errors.fixInstall the correct Java Development Kit (JDK) version (e.g., OpenJDK 17). Ensure the `JAVA_HOME` environment variable is set correctly and points to your JDK installation. For Spark integration, ensure `SPARK_HOME` and `PYSPARK_SUBMIT_ARGS` are also configured correctly.
affects: All versions
gotchaModels exported using one MLeap Python API version might not be compatible with an MLeap Scala/JVM runtime of a different version (and vice-versa). Serialization formats can change between releases, leading to load/prediction failures with `UnsupportedBundleFileVersionException` or similar when attempting to run models with mismatched versions.fixAlways use the same major.minor version of the `mleap` Python package and the `mleap-runtime` Scala library. When upgrading MLeap, it is highly recommended to re-export all existing models with the new version to ensure compatibility.
affects: All major/minor version upgrades
gotchaWhen exporting models, MLeap requires a sample DataFrame (or similar structure) to accurately infer the input schema of the model. Providing incorrect or incomplete input data during the `Bundle().writer` step can lead to models that fail to load or predict correctly at runtime due to schema mismatches, leading to runtime errors or unexpected behavior.fixEnsure the sample `pd.DataFrame` (or `pyspark.sql.DataFrame`) provided to `Bundle().writer` accurately reflects the exact structure (column names, data types, and order) of the data your model expects during inference. For pipelines, ensure all input features are represented in the sample data.
affects: All versions using `Bundle().writer`
Upgrade
Version history
0.25.2latest on PyPI · released Jul 21, 2026
Audit
Dependencies
numpyrequiredCore numerical operations and data handling.
scikit-learnrequiredIntegration with scikit-learn models for export/import.
scipyrequiredScientific computing dependency for scikit-learn.
pandasoptionalCommonly used for DataFrame input/output in examples and real-world usage.
pysparkoptionalRequired for Spark integration features, available via `mleap[spark]` extra.
onnxruntimeoptionalRequired for ONNX model support, available via `mleap[onnx]` extra.
Java Development Kit (JDK)requiredMLeap relies on a JVM for its runtime. Version 0.24.0 requires JDK 17. Must be installed separately and `JAVA_HOME` configured.