Install & Compatibility
Where this runs
tested against v0.19.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
py 3.10
✕ build_error
1/2 runs
py 3.11
✕ build_error
1/2 runs
py 3.12
✕ build_error
1/2 runs
py 3.13
✕ build_error
✕ build_error
py 3.9
✕ build_error
✓ 23.5s
277MB installed
● package 277MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
KServeClient
✓ from kserve import KServeClient
V1beta1InferenceService
✓ from kserve import V1beta1InferenceService
✗ from kfserving.models import V1beta1InferenceService
Class moved from deprecated kfserving package to kserve package and structure.
constants
✓ from kserve import constants
client
✓ from kubernetes import client as k8s_client
The Kubernetes client is a direct dependency for cluster interaction.
This quickstart demonstrates how to initialize the KServe client, define an InferenceService for a scikit-learn model, and deploy it to a Kubernetes cluster. It requires the `kubernetes` package and a configured `kubectl` context or running inside a Kubernetes pod.
import os
from kubernetes import client as k8s_client
from kserve import KServeClient, constants, utils
from kserve import V1beta1InferenceService, V1beta1InferenceServiceSpec, V1beta1PredictorSpec, V1beta1SKLearnSpec
# --- Configuration and Client Initialization ---
# This example assumes kubectl is configured to connect to a Kubernetes cluster.
# For in-cluster execution, uncomment `k8s_client.config.load_incluster_config()`.
# For local execution, ensure your ~/.kube/config is set up.
try:
k8s_client.config.load_kube_config()
except k8s_client.config.config_exception.ConfigException:
print("Warning: Could not load kube-config. Attempting in-cluster config.")
try:
k8s_client.config.load_incluster_config()
except k8s_client.config.config_exception.ConfigException:
print("Error: Could not load any Kubernetes config. Please ensure kubectl is configured or run within a cluster.")
exit(1)
api_version = constants.KSERVE_API_VERSION
kserve_client = KServeClient()
namespace = os.environ.get('K8S_NAMESPACE', 'default') # Use an environment variable or default
service_name = 'sklearn-iris-quickstart'
# --- Define an InferenceService ---
isvc = V1beta1InferenceService(
api_version=api_version,
kind=constants.KSERVE_KIND,
metadata=k8s_client.V1ObjectMeta(
name=service_name, namespace=namespace
),
spec=V1beta1InferenceServiceSpec(
predictor=V1beta1PredictorSpec(
sklearn=V1beta1SKLearnSpec(
storage_uri='gs://kfserving-examples/models/sklearn/iris',
protocol_version='v1'
)
)
)
)
print(f"Creating InferenceService '{service_name}' in namespace '{namespace}'...")
# --- Create and Wait for InferenceService ---
try:
kserve_client.create(isvc)
print(f"InferenceService '{service_name}' created. Waiting for it to be ready...")
kserve_client.wait_isvc_ready(service_name, namespace=namespace)
print(f"InferenceService '{service_name}' is ready:")
print(kserve_client.get(service_name, namespace=namespace))
# Example of how to delete the service:
# kserve_client.delete(service_name, namespace=namespace)
# print(f"InferenceService '{service_name}' deleted.")
except Exception as e:
print(f"Failed to create or wait for InferenceService: {e}")
# Attempt cleanup if creation partially succeeded but failed later
try:
kserve_client.delete(service_name, namespace=namespace)
print(f"Attempted cleanup of '{service_name}'.")
except Exception as cleanup_e:
print(f"Failed to clean up '{service_name}': {cleanup_e}")
kserve --version
Debug
Known issues
breakingThe project was renamed from KFServing to KServe. The Python package `kfserving` is deprecated and no longer maintained. Users must migrate to the `kserve` package.fixUninstall `kfserving` and `pip install kserve`. Update all imports from `from kfserving import ...` to `from kserve import ...`.
affects: <=0.7.0 (kfserving) to >=0.8.0 (kserve)
gotchaThe KServe Python SDK relies heavily on the official `kubernetes` Python client to interact with your cluster. This dependency is not automatically installed with `pip install kserve`.fixEnsure you install both: `pip install kserve kubernetes`. You will also need a correctly configured Kubernetes context (e.g., `~/.kube/config`) or run within a cluster.
affects: All versions
gotchaKServe's underlying Kubernetes API objects (like InferenceService) are evolving. While `v1beta1` is still widely used and supported by the SDK, future versions of KServe may promote `v1` as the primary API.fixAlways refer to the official KServe documentation for the specific version of KServe you are running on your cluster. Use the `constants.KSERVE_API_VERSION` provided by the SDK to ensure compatibility where possible, but be aware of potential manifest differences.
affects: All versions, particularly relevant for KServe >= 0.10.0
Upgrade
Version history
0.19.0latest on PyPI · released Jun 14, 2026
Audit
Dependencies
kubernetesrequiredRequired to interact with Kubernetes clusters and manage KServe resources.