Skip to content

pip installation fails for older Python versions (3.8, 3.7) #113

@CalvinAllen

Description

@CalvinAllen

Description

When installing older Python versions like 3.8.9, the pip installation step fails with a warning. The latest get-pip.py from https://bootstrap.pypa.io/get-pip.py no longer supports end-of-life Python versions.

Steps to Reproduce

  1. Have a newer Python version installed and set as global (e.g., 3.9.9)
  2. Install an older Python version: dtvem install python 3.8.9
  3. Pip installation fails with warning

Error Output

✓ Python v3.8.9 installed successfully
→ Location: C:\Users\calvin.allen\.dtvem\versions\python\3.8.9
Downloading 100% |████████████████████████████████████████████████████████████| (2.2/2.2 MB, 12 MB/s)

⚠ Failed to install pip
→ You can install it manually by running: python -m ensurepip

Root Cause

The bootstrap.pypa.io/get-pip.py script dropped support for older Python versions. For EOL Python versions, we need to use version-specific URLs:

  • Python 3.8: https://bootstrap.pypa.io/pip/3.8/get-pip.py
  • Python 3.7: https://bootstrap.pypa.io/pip/3.7/get-pip.py
  • Python 3.6: https://bootstrap.pypa.io/pip/3.6/get-pip.py

Proposed Fix

Update installPip() in the Python provider to detect the Python minor version and use the appropriate get-pip.py URL:

func (p *Provider) getPipURL(version string) string {
    parts := strings.Split(version, ".")
    if len(parts) >= 2 {
        minor, _ := strconv.Atoi(parts[1])
        if parts[0] == "3" && minor <= 8 {
            return fmt.Sprintf("https://bootstrap.pypa.io/pip/%s.%s/get-pip.py", parts[0], parts[1])
        }
    }
    return "https://bootstrap.pypa.io/get-pip.py"
}

Additional Issue: Incorrect Fallback Instructions

The current fallback message says:

→ You can install it manually by running: python -m ensurepip

This is incorrect because Windows embeddable Python packages do not include ensurepip - it's stripped out to keep the package small. Running this command results in:

C:\Users\calvin.allen\.dtvem\versions\python\3.8.9\python.exe: No module named ensurepip

The fallback instructions should be updated to:

→ To install pip manually:
→   1. Download: https://bootstrap.pypa.io/get-pip.py
→   2. Run: python get-pip.py

Acceptance Criteria

  • Detect Python version and use appropriate get-pip.py URL
  • Fix the fallback instructions to not reference ensurepip
  • Test with Python 3.8.x, 3.9.x, and 3.12.x
  • Add tests for the URL selection logic

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions