mlflow/mlflow · error · MlflowException
Databricks spark job only supports 'python' command in the e
Error message
Databricks spark job only supports 'python' command in the entry point configuration.
What it means
When a project's databricks_spark_job spec does not define python_file/parameters, MLflow computes the entry point's command and requires it to be a plain `python ...` invocation, since Databricks Spark jobs can only execute Python scripts this way. A non-python command raises this MlflowException.
Source
Thrown at mlflow/projects/databricks.py:300
_logger.info(
"=== Running databricks spark job of project %s on Databricks ===", project_uri
)
if project_spec.databricks_spark_job_spec.python_file is not None:
if entry_point != "main" or parameters:
_logger.warning(
"You configured Databricks spark job python_file and parameters within the "
"MLProject file's databricks_spark_job section. '--entry-point' "
"and '--param-list' arguments specified in the 'mlflow run' command are "
"ignored."
)
job_code_file = project_spec.databricks_spark_job_spec.python_file
job_parameters = project_spec.databricks_spark_job_spec.parameters
else:
command = project_spec.get_entry_point(entry_point).compute_command(parameters, None)
command_splits = command.split(" ")
if command_splits[0] != "python":
raise MlflowException(
"Databricks spark job only supports 'python' command in the entry point "
"configuration."
)
job_code_file = command_splits[1]
job_parameters = command_splits[2:]
tmp_dir = Path(get_or_create_tmp_dir())
origin_job_code = (Path(work_dir) / job_code_file).read_text()
job_code_filename = f"{uuid.uuid4().hex}.py"
new_job_code_file = tmp_dir / job_code_filename
project_dir, extracting_tar_command = _get_project_dir_and_extracting_tar_command(
dbfs_fuse_uri
)
env_vars_str = json.dumps(env_vars)
new_job_code_file.write_text(
f"""View on GitHub (pinned to 6a27f2decc)
Solutions
- Rewrite the entry point command so the first token is `python` and the second token is the script file
- Move setup steps out of the command into the Python script itself
- Use the databricks_spark_job spec with an explicit python_file instead of relying on command computation
Example fix
// before
class MLproject
entry_points:
main:
command: "bash run.sh"
// after
entry_points:
main:
command: "python train.py --alpha {alpha}" Defensive patterns
Strategy: validation
Validate before calling
cmd = project.get_entry_point('main').command
assert cmd.split(' ')[0] == 'python', 'Databricks spark job entry points must start with python' Type guard
null
Try / catch
from mlflow.exceptions import MlflowException
try:
run_databricks_spark_job(...)
except MlflowException as e:
if "only supports 'python' command" in str(e):
rewrite_entry_point_to_python() Prevention
- Keep Databricks entry point commands in the form 'python script.py ...'
- Move shell setup logic into the Python script or a docker env instead
- Prefer explicit python_file in databricks_spark_job specs
When it happens
Trigger: Defining an MLproject entry point whose command starts with something other than `python` (e.g. `bash script.sh`, `spark-submit`, `python3 -m ...` wrappers are still fine only if the first token is `python`) and running it via `backend='databricks'` with the databricks_spark_job spec.
Common situations: MLproject written for local execution uses shell commands; entry point wraps python in a shell script; multi-token commands where the first token is not literally 'python'.
Related errors
- Running docker-based projects on Databricks is not yet suppo
- The entry point '{entry_point}' is not defined in the Databr
- Backend spec must be provided when launching MLflow project
- INVALID_PARAMETER_VALUE
- When running on Databricks, the MLflow tracking URI must be
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/fc5e27642cfb894d.
Report an issue: GitHub.