Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught FileNotFoundError when pip3 not found (pure UV environments) #5046

Open
andylizf opened this issue Mar 27, 2025 · 1 comment
Open

Comments

@andylizf
Copy link
Collaborator

andylizf commented Mar 27, 2025

When using SkyPilot in an environment with UV instead of pip3, the wheel building process fails with an uncaught FileNotFoundError instead of the expected CalledProcessError.

  File "/home/andy/Power-RAG/.venv/lib/python3.10/site-packages/sky/backends/cloud_vm_ray_backend.py", line 2834, in _provision
    local_wheel_path, wheel_hash = wheel_utils.build_sky_wheel()
  File "/home/andy/Power-RAG/.venv/lib/python3.10/site-packages/sky/backends/wheel_utils.py", line 179, in build_sky_wheel
    latest_wheel = _build_sky_wheel()
  File "/home/andy/Power-RAG/.venv/lib/python3.10/site-packages/sky/backends/wheel_utils.py", line 103, in _build_sky_wheel
    subprocess.run([
  File "/home/andy/.local/share/uv/python/cpython-3.10.16-linux-x86_64-gnu/lib/python3.10/subprocess.py", line 503, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/home/andy/.local/share/uv/python/cpython-3.10.16-linux-x86_64-gnu/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/andy/.local/share/uv/python/cpython-3.10.16-linux-x86_64-gnu/lib/python3.10/subprocess.py", line 1863, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'pip3'

That's because the following code tries to run pip3 wheel but doesn't properly catch the error when pip3 is missing entirely:

try:
# TODO(suquark): For python>=3.7, 'subprocess.run' supports capture
# of the output.
subprocess.run([
'pip3', 'wheel', '--no-deps', norm_path, '--wheel-dir',
str(tmp_dir)
],
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
check=True)
except subprocess.CalledProcessError as e:
raise RuntimeError('Failed to build pip wheel for SkyPilot. '
f'Error message: {e.stderr.decode()}') from e

A quick fix is to add FileNotFoundError to the except block, like:

try:
    subprocess.run([...])
except (subprocess.CalledProcessError, FileNotFoundError) as e:
    if isinstance(e, FileNotFoundError):
        msg = "pip3 not found. Please install pip3."
    else:
        msg = f'Error message: {e.stderr.decode()}'
    raise RuntimeError('Failed to build pip wheel for SkyPilot. ' + msg) from e

We should further consider adding support for UV-only environments by checking for both pip3 and UV availability.

@cg505
Copy link
Collaborator

cg505 commented Mar 28, 2025

We should make this work in a full uv env. We can

  1. Depend on pip to make sure it's installed.
  2. If needed, use python -m pip to avoid any PATH issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants