{"record":{"id":"fc5e27642cfb894d","repo":"mlflow/mlflow","slug":"databricks-spark-job-only-supports-python-comman","errorCode":null,"errorMessage":"Databricks spark job only supports 'python' command in the entry point configuration.","messagePattern":"Databricks spark job only supports 'python' command in the entry point configuration\\.","errorType":"exception","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/projects/databricks.py","lineNumber":300,"sourceCode":"        _logger.info(\n            \"=== Running databricks spark job of project %s on Databricks ===\", project_uri\n        )\n\n        if project_spec.databricks_spark_job_spec.python_file is not None:\n            if entry_point != \"main\" or parameters:\n                _logger.warning(\n                    \"You configured Databricks spark job python_file and parameters within the \"\n                    \"MLProject file's databricks_spark_job section. '--entry-point' \"\n                    \"and '--param-list' arguments specified in the 'mlflow run' command are \"\n                    \"ignored.\"\n                )\n            job_code_file = project_spec.databricks_spark_job_spec.python_file\n            job_parameters = project_spec.databricks_spark_job_spec.parameters\n        else:\n            command = project_spec.get_entry_point(entry_point).compute_command(parameters, None)\n            command_splits = command.split(\" \")\n            if command_splits[0] != \"python\":\n                raise MlflowException(\n                    \"Databricks spark job only supports 'python' command in the entry point \"\n                    \"configuration.\"\n                )\n            job_code_file = command_splits[1]\n            job_parameters = command_splits[2:]\n\n        tmp_dir = Path(get_or_create_tmp_dir())\n        origin_job_code = (Path(work_dir) / job_code_file).read_text()\n        job_code_filename = f\"{uuid.uuid4().hex}.py\"\n        new_job_code_file = tmp_dir / job_code_filename\n\n        project_dir, extracting_tar_command = _get_project_dir_and_extracting_tar_command(\n            dbfs_fuse_uri\n        )\n\n        env_vars_str = json.dumps(env_vars)\n        new_job_code_file.write_text(\n            f\"\"\"","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/projects/databricks.py#L282-L318","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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"],"exampleFix":"// before\nclass MLproject\nentry_points:\n  main:\n    command: \"bash run.sh\"\n// after\nentry_points:\n  main:\n    command: \"python train.py --alpha {alpha}\"","handlingStrategy":"validation","validationCode":"cmd = project.get_entry_point('main').command\nassert cmd.split(' ')[0] == 'python', 'Databricks spark job entry points must start with python'","typeGuard":"null","tryCatchPattern":"from mlflow.exceptions import MlflowException\ntry:\n    run_databricks_spark_job(...)\nexcept MlflowException as e:\n    if \"only supports 'python' command\" in str(e):\n        rewrite_entry_point_to_python()","preventionTips":["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"],"tags":["databricks","projects","spark-job"],"backgroundTag":"unsupported-parameter-value","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}