@@ -12,6 +12,7 @@ import (
1212 "regexp"
1313 goruntime "runtime"
1414 "sort"
15+ "strconv"
1516 "strings"
1617 "time"
1718
@@ -117,7 +118,9 @@ func (p *Provider) installPipIfNeeded(version string) {
117118 pipSpinner .Start ()
118119 if err := p .installPip (version ); err != nil {
119120 pipSpinner .Warning ("Failed to install pip" )
120- ui .Info ("You can install it manually by running: python -m ensurepip" )
121+ ui .Info ("To install pip manually:" )
122+ ui .Info (" 1. Download: %s" , p .getPipURL (version ))
123+ ui .Info (" 2. Run: python get-pip.py" )
121124 } else {
122125 pipSpinner .Success ("pip installed successfully" )
123126 }
@@ -306,8 +309,8 @@ func (p *Provider) installPip(version string) error {
306309 return fmt .Errorf ("failed to enable site-packages: %w" , err )
307310 }
308311
309- // Step 2: Download get-pip.py
310- getPipURL := "https://bootstrap.pypa.io/get-pip.py"
312+ // Step 2: Download get-pip.py (use version-specific URL for older Python)
313+ getPipURL := p . getPipURL ( version )
311314 getPipPath := filepath .Join (installPath , "get-pip.py" )
312315 if err := download .File (getPipURL , getPipPath ); err != nil {
313316 return fmt .Errorf ("failed to download get-pip.py: %w" , err )
@@ -325,6 +328,22 @@ func (p *Provider) installPip(version string) error {
325328 return nil
326329}
327330
331+ // getPipURL returns the appropriate get-pip.py URL for the given Python version.
332+ // Older Python versions (3.8 and below) require version-specific URLs since the
333+ // main get-pip.py no longer supports end-of-life Python versions.
334+ func (p * Provider ) getPipURL (version string ) string {
335+ parts := strings .Split (version , "." )
336+ if len (parts ) >= 2 && parts [0 ] == "3" {
337+ minor , err := strconv .Atoi (parts [1 ])
338+ if err == nil && minor <= 8 {
339+ // Use version-specific URL for Python 3.8 and below
340+ return fmt .Sprintf ("https://bootstrap.pypa.io/pip/%s.%s/get-pip.py" , parts [0 ], parts [1 ])
341+ }
342+ }
343+ // Default URL for Python 3.9+
344+ return "https://bootstrap.pypa.io/get-pip.py"
345+ }
346+
328347// enableSitePackages modifies the ._pth file to enable site-packages
329348func (p * Provider ) enableSitePackages (pthFile string ) error {
330349 // Read the file
0 commit comments