diff --git a/providers/standard/src/airflow/providers/standard/utils/python_virtualenv.py b/providers/standard/src/airflow/providers/standard/utils/python_virtualenv.py index 37ab5bee497ab..d89d0ed89717a 100644 --- a/providers/standard/src/airflow/providers/standard/utils/python_virtualenv.py +++ b/providers/standard/src/airflow/providers/standard/utils/python_virtualenv.py @@ -21,6 +21,7 @@ import os import shutil +import warnings from pathlib import Path import jinja2 @@ -55,6 +56,15 @@ def _use_uv() -> bool: def _generate_uv_cmd(tmp_dir: str, python_bin: str, system_site_packages: bool) -> list[str]: """Build the command to install the venv via UV.""" + if python_bin == "python" or python_bin == "python3": + python_interpreter_exists = bool(shutil.which(python_bin)) + if not python_interpreter_exists: + warnings.warn( + f"uv trying to use `{python_bin}` as the python interpreter. it could lead to errors if the python interpreter not found in PATH. " + f"please specify python_version in operator.", + UserWarning, + stacklevel=3, + ) cmd = ["uv", "venv", "--allow-existing", "--seed", "--python", python_bin] if system_site_packages: cmd.append("--system-site-packages")