Download here:
http://python.org/ftp/python/2.7.6/python-2.7.6.msi
Accept all the default options.
- Open the systen environment variables
- If you own Windows 8:
- Go to the start screen, and type "Edit the system environment variables".
- Click the option that appears
- If you own a different Windows computer:
- Right-click on "My Computer"
- Click "Advanced System Settings" from the left.
-
Click the "Environment Variables" in the bottom of the window
-
Under "System Variables" look for the "path" variable. Click it to highlight it, and click the "Edit" button.
-
At the very end, add the following:
;C:\Python27;C:\Python27\Scripts\
-
Save and exit.
Download the following
http://peak.telecommunity.com/dist/ez_setup.py
-
Open command line. (type 'cmd' in the "run" box from the start menu)
-
Navigate to wherever you downloaded the file using the
cdcommand. For example, if I saved the file underC:\Users\Michael\Downloads, then I would type:cd "C:\Users\Michael\Downloads" -
Run the following:
python ez_install.py
Note: Make sure you're within the command line. You can execute the following set of lines from any folder
Type the following, one by one.
easy_install pip
pip install virtualenv
pip install future
pip install pylint
pip install radon
pip install pytest
pip install distribute
pip install yolk
pip install docopt
pip install requests
If any of these packages fails, note down the name, and move on to the next one.
Download and install the following:
http://pygame.org/ftp/pygame-1.9.1.win32-py2.7.msi
Copy the following into a file called test.py. Navigate to it within the command line,
and run python test.py. If everything went well, you should see a narrow window appear
with a bunch of moving colored balls.
#!/usr/bin/env python
# Testing normal imports
import math
import random
# Testing pygame
import pygame
# Testing other imports (they're not used)
import future
import docopt
import requests
WIDTH = 400
HEIGHT = 600
def main():
pygame.init()
screen = pygame.display.set_mode([WIDTH, HEIGHT])
balls = generate_random_balls(20)
while True:
screen.fill([0, 0, 0]) # Black
for ball in balls:
ball.move()
ball.draw(screen)
pygame.display.flip()
event = pygame.event.poll()
if event.type == pygame.QUIT:
pygame.quit()
break
def generate_random_balls(amount):
balls = []
for i in range(amount):
x = random.randint(0, WIDTH)
y = random.randint(0, HEIGHT)
dx = random.randint(-2, 2)
dy = random.randint(-2, 2)
balls.append(Ball(x, y, dx, dy))
return balls
def random_color():
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
return [r, g, b]
class Ball(object):
def __init__(self, x, y, dx, dy):
'''Creates a moving ball.'''
self.x = x
self.y = y
self.dx = dx
self.dy = dy
self.color = random_color()
def move(self):
if not 0 < self.x < WIDTH:
self.dx = -self.dx
if not 0 < self.y < HEIGHT:
self.dy = -self.dy
self.x += self.dx
self.y += self.dy
def draw(self, screen):
pygame.draw.circle(screen, self.color, [self.x, self.y], 5)
if __name__ == '__main__':
main()