Install & Compatibility
Where this runs
tested against v0.133.0 · 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.95 runs
build_error
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 14.3s · import 4.504s · 351MB
363MB installed
● package 363MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
PMMLPipeline
✓ from sklearn2pmml.pipeline import PMMLPipeline
sklearn2pmml
✓ from sklearn2pmml import sklearn2pmml
✗ from sklearn2pmml import make_pmml_pipeline
The `make_pmml_pipeline` utility function has been removed or deprecated in favor of directly using `PMMLPipeline` and `sklearn2pmml()`.
This quickstart demonstrates how to create a Scikit-Learn pipeline, wrap it with `PMMLPipeline`, fit the model, and then export it to a PMML file using the `sklearn2pmml()` function. The `PMMLPipeline` class enhances the standard Scikit-Learn pipeline with PMML-specific functionalities like capturing feature names from Pandas DataFrames.
import pandas as pd
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
from sklearn2pmml.pipeline import PMMLPipeline
from sklearn2pmml import sklearn2pmml
# Load a sample dataset
iris = load_iris(as_frame=True)
X, y = iris.data, iris.target
# Create a PMMLPipeline (extends sklearn.pipeline.Pipeline)
pmml_pipeline = PMMLPipeline([
('classifier', DecisionTreeClassifier())
])
# Fit the pipeline
pmml_pipeline.fit(X, y)
# Convert the fitted pipeline to PMML
pmml_filepath = 'DecisionTreeIris.pmml'
sklearn2pmml(pmml_pipeline, pmml_filepath)
print(f"PMML model successfully exported to {pmml_filepath}")
Debug
Known issues
breakingThe `sklearn2pmml.make_pmml_pipeline()` utility function has been removed. Additionally, the `escape_func` parameter was moved from `make_pmml_pipeline()` to the `sklearn2pmml()` function.fixDirectly use `sklearn2pmml.pipeline.PMMLPipeline` for pipeline creation and pass `escape_func` (if needed) to `sklearn2pmml()`.
affects: 0.120.0 and newer
gotchasklearn2pmml is a Python wrapper for a Java library and requires a Java Runtime Environment (JRE) version 11 or newer to be installed and accessible via the system's PATH environment variable. Without Java, conversion attempts will fail with a `RuntimeError`.fixEnsure Java 11+ is installed and configured correctly on your system path.
affects: All versions
gotchaThe `sklearn2pmml` library is designed for *exporting* Scikit-learn models to PMML. It does not provide functionality to *import* PMML files back into Scikit-learn objects or Python for native scoring. For Python-based PMML evaluation, consider using the `jpmml-evaluator-python` library.fixUse `jpmml-evaluator-python` or another PMML evaluation library if you need to score PMML files within Python.
affects: All versions
gotchaWhen training models within `PMMLPipeline`, using `pandas.DataFrame` or `pandas.Series` for `X` and `y` is recommended. This allows `sklearn2pmml` to correctly capture and embed meaningful feature and target names in the PMML file. If NumPy arrays are used, feature names will default to generic 'x1', 'x2', etc., and the target name to 'y'.fixPass `X` and `y` as `pandas.DataFrame` and `pandas.Series` objects, respectively, to the `fit()` method of `PMMLPipeline`.
affects: All versions
gotchaDirect conversion of highly custom Python classes, especially for complex data preprocessing (e.g., advanced text feature extraction using third-party libraries), is generally not supported. PMML has a limited set of expressible transformations, and arbitrary Python code cannot be translated.fixRefactor complex custom preprocessing steps into simpler, PMML-compatible transformers where possible, or perform them external to the PMML pipeline.
affects: All versions
gotchaConversion of large or complex models can lead to out-of-memory errors in the underlying Java process. This often manifests as a `RuntimeError` with Java-related stack traces.fixIncrease the Java Virtual Machine (JVM) memory allocation by passing `java_opts` to the `sklearn2pmml()` function, e.g., `sklearn2pmml(pipeline, 'model.pmml', java_opts=['-Xms4096m', '-Xmx4096m'])` to allocate 4GB of heap space.
affects: All versions
Errors
Common errors & fixes
OSError: [Errno 2] No such file or directory: 'java'
The 'java' executable is not found in the system's PATH, or JAVA_HOME is not correctly set, which prevents sklearn2pmml from invoking the underlying JPMML-SkLearn Java library.
fixInstall a Java Development Kit (JDK) and ensure the 'java' executable is accessible via your system's PATH, or set the JAVA_HOME environment variable to the JDK installation directory.
ModuleNotFoundError: No module named 'sklearn2pmml'
The 'sklearn2pmml' library has not been installed in the current Python environment or the environment is not active.
fixInstall the library using pip: `pip install sklearn2pmml`
sklearn2pmml.converter.ConversionError: Type '...' is not a JPMML-SkLearn supported ...
The Scikit-Learn estimator, transformer, or specific configuration used in the pipeline is not yet supported by the underlying JPMML-SkLearn Java library.
fixRefer to the `jpmml-sklearn` documentation for a list of supported Scikit-Learn components and consider replacing unsupported parts of your pipeline with supported alternatives, or use a custom transformer that can be converted.
AttributeError: 'ColumnTransformer' object has no attribute 'transformers_'
This error typically indicates a version incompatibility between `sklearn2pmml` and the installed `scikit-learn` library, or that the `ColumnTransformer` (or pipeline) has not been fitted before conversion.
fixEnsure your Scikit-Learn version is compatible with `sklearn2pmml` (check documentation for requirements), and always `fit()` your pipeline or estimator before attempting to convert it to PMML. If the issue persists, downgrade or upgrade `scikit-learn` to a compatible version.
Upgrade
Version history
0.133.0latest on PyPI · released Aug 19, 2026
Audit
Dependencies
Java 11 or newerrequiredsklearn2pmml is a wrapper around a Java library (JPMML-SkLearn) and requires a compatible Java Runtime Environment (JRE) to be installed and available on the system path.
scikit-learnrequiredCore functionality involves converting Scikit-Learn models and pipelines.
jpmml-evaluatoroptionalUsed for evaluating (scoring) PMML models in Python, often in conjunction with models generated by sklearn2pmml.