Skip to content

Instantly share code, notes, and snippets.

@yumusb
Created August 27, 2022 23:20
Show Gist options
  • Save yumusb/31bbbc9587708fd37425bb5c43309759 to your computer and use it in GitHub Desktop.
Save yumusb/31bbbc9587708fd37425bb5c43309759 to your computer and use it in GitHub Desktop.
import sys
def httpget(url):
if sys.version_info.major == 2:
import urllib2
req = urllib2.Request(url)
data = urllib2.urlopen(req).read()
return data
else:
import urllib.request
data = urllib.request.urlopen(url).read()
return data
base = "https://bootstrap.pypa.io/pip/"
basefilename = "get-pip.py"
remoteverpath = ["2.6","2.7","3.2","3.3","3.4","3.5","3.6"]
locver = str(sys.version_info.major)+"."+str(sys.version_info.minor)
if locver in remoteverpath:
url = base + locver + "/" + basefilename
else:
url = base + basefilename
exec(httpget(url))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment