Note that there are some explanatory texts on larger screens.

plurals
  1. POImportError: no module named pygame?
    primarykey
    data
    text
    <p>I can import pygame through the command line, and through all my other prorams, but it brings up an error in my crosshairs program:</p> <p>Traceback (most recent call last): File "C:\Users\Family\Desktop\pys\Crosshairs(2).py", line 1, in import pygame ImportError: No module named 'pygame'</p> <p>I have no idea what the heck it's talking about, but I'm thinking this could be windows vista being a crap hole(vista is verry glitchy) but I'm not too sure. Does anyone know what the problem is? If you need it, here is the code:</p> <pre><code>import pygame import math import sys WHITE = (255, 255, 255) BLACK = ( 0, 0, 0) RED = (255, 0, 0) BGCOLOR = WHITE WINDOWWIDTH = 640 WINDOWHEIGHT = 480 class Control(object): def __init__(self): self.bullet_holes = [] self.screen = pg.display.set_mode((WINDOWWIDTH,WINDOWHEIGHT)) self.done = False self.clock = pg.time.Clock() def update(self): vis = False pygame.mouse.get_visible(vis) self.mousex,self.mousey = pg.mouse.get_pos() self.screen.fill(BGCOLOR) pygame.draw.circle(self.screen, RED, (320,240),50,10) pygame.draw.circle(self.screen, WHITE, (320,240),40,10) pygame.draw.circle(self.screen, RED, (320,240),30,10) pygame.draw.circle(self.screen, WHITE, (320,240),20,10) pygame.draw.circle(self.screen, RED, (320,240),10,10) pygame.draw.line(self.screen, BLACK, (self.mousex - 2000, self.mousey), (self.mousex + 2000, self.mousey)) pygame.draw.line(self.screen, BLACK, (self.mousex, self.mousey - 2000), (self.mousex, self.mousey + 2000)) for bullet_pos in self.bullet_holes: pygame.draw.circle(self.screen,BLACK,bullet_pos,5) def event_loop(self): for event in pg.event.get(): if event.type == pg.QUIT or (event.type == pg.KEYUP and event.key==pg.K_ESCAPE): self.done = True elif event.type == pg.MOUSEBUTTONDOWN and event.button == 1: self.bullet_holes.append(event.pos) pygame.image.save(self.screen,'Highscores.png') def main_loop(self): while not self.done: self.update() self.event_loop() pygame.display.flip() self.clock.tick(60) if __name__ == '__main__': game = Control() game.main_loop() pygame.quit() sys.exit() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload