Applies to:
- Plan - Enterprise
- Deployment - Self-hosted (GCP, Azure)
- Use case - Running Python scorers with native dependencies on a self-hosted data plane
Summary
Issue: A Python scorer fails with an import error when you invoke it on a self-hosted GCP or Azure data plane. One example iscannot import name 'cygrpc' from 'grpc._cython'.
Cause: The scorer bundle contains a native Python extension built for a different Python version or CPU architecture than the API runtime that executes the scorer.
Resolution: Build and push the scorer with a Python interpreter and architecture that match the self-hosted API runtime.
Symptoms
The scorer pushes successfully, but invocation returns an HTTP 500 error. The error includes details similar to:cygrpc.cpython-312-x86_64-linux-gnu.so cannot load that extension in Python 3.11.
This issue affects packages with compiled extensions.
Cause
On self-hosted GCP and Azure deployments, Python scorer code runs in the API container. The Python version is determined by the OS image. The Python interpreter used bybt functions push determines which wheel or native extension is placed in the scorer bundle.
The --runner option controls the interpreter used to build the bundle. It does not change the interpreter in the API container. If you build with Python 3.12 and invoke on a Python 3.11 API runtime, Python looks for a cpython-311 extension. A cpython-312 extension does not load.
CPU architecture must also match. For example, an x86_64 extension does not load in an aarch64 runtime.
Resolution steps
Step 1: Check the API runtime
Check the Python version and architecture in an API pod:Step 2: Check the bundle build interpreter
Run these commands from the scorer’s development environment:Step 3: Recreate the environment with the matching Python version
Create a virtual environment with the Python version used by the API runtime. For example, if the API runtime reports Python 3.11:Step 4: Invoke the scorer again
How to confirm it worked
The scorer should invoke without the native-extension import error. To verify the exact versions used by the scorer, temporarily include diagnostic information in the scorer output or error:Notes
- This issue is specific to native dependencies. Pure-Python packages generally do not contain interpreter-specific
.soextensions. - AWS Lambda deployments use separately selected Lambda runtimes and do not use this Kubernetes API-container execution path.