i have been coding a window in pygame and the code starts with this:
import pygame, sys
from pygame.locals import *
pygame.init()
and i get this error wen i try to run it:
Traceback (most recent call last):
File "pyg2.py", line 2, in <module>
from pygame.locals import *
ImportError: No module named locals
just in case, here is my full code:
import pygame, sys
from pygame.locals import *
pygame.init()
def create_window():
global window, window_height, window_width, window_title
window_width, window_height = 800,600
window_title = "WINXP Settings"
pygame.display.set_caption(window_title)
window = pygame.display.set_mode((window_width, window_height),
pygame.HWSURFACE|pygame.DOUBLEBUF)
create_window()
isRunning = True
while isRunning:
for event in pygame.event.get():
if event.type == pygame.QUIT:
isRunning = False
window.fill((0, 0, 0))
pygame.display.update()
pygame.quit()
sys.exit()
oh yeah, My computer is linux lubuntu, not Windows XP, just in case
window_title = "WINXP Settings"
threw you off.
My guess is that you have a file named pygame.py in the current directory in which you are running the script. If so, change the file's name and try again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.