Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A pure python script to download and install the distribute_setup and pip utilities. Tested on Windows 7, Python 3.2.
A pure python script to download and install the distribute_setup and
pip utilities
Adapted from:
matt wilkie <>
license: X/MIT
import sys
sources = [
warning = '''\n
Usage: python %s GO
This script downloads and executes arbitrary code from the internet.
It is worth noting this could be extremely dangerous if one doesn't
have the expertise or bother to inspect the url-file before executing
these commands.
At the time of this writing said arbitrary code is:
''' % (sys.argv[0])
for s in sources:
warning = warning + '\n\t %s' % s
if not len(sys.argv) > 1:
if not sys.argv[1] == 'GO':
if sys.hexversion < 0x03000000:
from urllib2 import urlopen # python 2
from urllib.request import urlopen # python 3+
for src in sources:
print('\n %s \n %s \n' % ('-'*78, src))
f = urlopen(src).read()
try: exec(f)
**** Whups. an exception happened in "exec(f)" of %s.
**** Carrying on anyway,
**** but you should check to ensure it's not a real problem.
''' % sys.argv[0])
print('\n %s \n %s \n' % (src, '-'*78))

maphew commented Apr 17, 2013

hmm, on a virgin python install the script needs to be run twice. The first time distribute installs and get-pip is skipped over. On the second get-pip works.


maphew commented Apr 21, 2013

...interesting, on python3.2 it doesn't need to be run twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment