Skip to content

Install Python via uv when no Python is found #1172

@karthiknadig

Description

@karthiknadig

Summary

When no Python interpreter is found on the user's machine, offer to install Python using uv - a fast, cross-platform Python installer and package manager.

Motivation

Users new to Python or setting up a fresh machine often don't have Python installed. Currently, they need to manually install Python before using the extension. We can streamline this experience by leveraging uv to automatically install Python.

Proposed Behavior

Scenario 1: No Python found, no uv found

  1. Detect that no Python interpreter is available
  2. Prompt user: "No Python found. Would you like to install Python using uv?"
  3. If user agrees:
    • Install uv using platform-appropriate method:
      • Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
      • macOS/Linux: curl -LsSf https://astral.sh/uv/install.sh | sh
    • Run uv python install to install the latest Python version
  4. Refresh environment detection

Scenario 2: No Python found, uv already installed

  1. Detect that no Python interpreter is available but uv is present
  2. Prompt user: "No Python found. Would you like to install Python using uv?"
  3. If user agrees:
    • Run uv python install to install the latest Python version
  4. Refresh environment detection

Benefits of using uv

  • Cross-platform: Single consistent approach for Windows, macOS, and Linux
  • No bootstrap problem: uv can install Python without requiring Python first
  • Fast: Rust-based, significantly faster than traditional installers
  • Multiple versions: Users can later install additional Python versions with uv python install 3.x
  • Maintained: Actively developed by Astral (creators of Ruff)

Implementation Considerations

  • Detect if uv is already installed (check PATH)
  • Handle installation failures gracefully
  • Consider allowing user to choose Python version (optional enhancement)
  • Update environment detection after installation
  • Consider adding a "Don't ask again" option
  • Ensure terminal visibility so users can see installation progress

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions