mlflow/mlflow · error · Exception
You need to set either {_JOHNSNOWLABS_ENV_HEALTHCARE_SECRET}
Error message
You need to set either {_JOHNSNOWLABS_ENV_HEALTHCARE_SECRET} or {_JOHNSNOWLABS_ENV_VISUAL_SECRET} environment variable. Please contact John Snow Labs to get one. What it means
get_default_pip_requirements needs to build a wheel URI for the John Snow Labs healthcare/visual NLP libraries, which requires an JSL secret. It raises when neither the healthcare secret nor the visual secret environment variable is set, telling the user to obtain one from John Snow Labs.
Source
Thrown at mlflow/johnsnowlabs/__init__.py:148
# if json license is detected, we parse it and set the env vars
loaded_license = json.loads(os.environ[_JOHNSNOWLABS_ENV_JSON_LICENSE_KEY])
os.environ.update({k: str(v) for k, v in loaded_license.items() if v is not None})
def get_default_pip_requirements():
"""
Returns:
A list of default pip requirements for MLflow Models produced by this flavor.
Calls to :func:`save_model()` and :func:`log_model()` produce a pip environment
that, at minimum, contains these requirements.
"""
from johnsnowlabs import settings
if (
_JOHNSNOWLABS_ENV_HEALTHCARE_SECRET not in os.environ
and _JOHNSNOWLABS_ENV_VISUAL_SECRET not in os.environ
):
raise Exception(
f"You need to set either {_JOHNSNOWLABS_ENV_HEALTHCARE_SECRET} "
f"or {_JOHNSNOWLABS_ENV_VISUAL_SECRET} environment variable. "
f"Please contact John Snow Labs to get one."
)
_SPARK_NLP_JSL_WHEEL_URI = (
"https://pypi.johnsnowlabs.com/{secret}/spark-nlp-jsl/spark_nlp_jsl-"
+ f"{settings.raw_version_medical}-py3-none-any.whl"
)
_SPARK_NLP_VISUAL_WHEEL_URI = (
"https://pypi.johnsnowlabs.com/{secret}/spark-ocr/"
f"spark_ocr-{settings.raw_version_ocr}-py3-none-any.whl"
)
deps = [
f"johnsnowlabs_for_databricks=={settings.raw_version_jsl_lib}",
_get_pinned_requirement("pyspark"),View on GitHub (pinned to 6a27f2decc)
Solutions
- Set the healthcare secret env var (from John Snow Labs)
- Or set the visual NLP secret env var if using Visual NLP
- Contact John Snow Labs to obtain a secret if you don't have one
Example fix
// before mlflow.johnsnowlabs.save_model(...) // after export JOHNSNOWLABS_HEALTHCARE_SECRET=xxxx mlflow.johnsnowlabs.save_model(...)
Defensive patterns
Strategy: validation
Validate before calling
import os
if not (os.environ.get("JOHNSNOWLABS_HEALTHCARE_SECRET") or os.environ.get("JOHNSNOWLABS_VISUAL_SECRET")):
raise RuntimeError("Set either the JSL healthcare or visual NLP secret env var") Try / catch
try:
requirements = mlflow.johnsnowlabs.get_default_pip_requirements()
except Exception as e:
if "environment variable" in str(e):
raise RuntimeError("Provide a JSL healthcare/visual secret from John Snow Labs") from e
raise Prevention
- Inject both license and secret env vars together in CI/Docker
- Know which JSL product (healthcare vs visual) you use and set the matching secret
- Contact John Snow Labs early to obtain secrets for new environments
When it happens
Trigger: Calling get_default_conda_env / get_default_pip_requirements (indirectly via save_model/log_model metadata) without either secret env var set.
Common situations: Saving a JSL model without healthcare/visual NLP credentials; shared environments where only the license.json was provided but not the download secret.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- Please set the {_JOHNSNOWLABS_ENV_JSON_LICENSE_KEY} environm
- No deployments target has been set. Please either set the ML
- A static secret key needs to be set for CSRF protection. Ple
- {STATIC_PREFIX_ENV_VAR} must not contain '{' or '}'.
- INVALID_PARAMETER_VALUE
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/3f1fb5f9c3f6cca5.
Report an issue: GitHub.