I just downloaded Pygame but is running into an error: AttributeError: module 'pygame' has no attribute 'init'. I was looking around on stackoverflow and someone fixed the error by renaming the files (which I don't know how to do). The directory is the following
Python -> Lib -> site-packages ->pygame
The confusing part for me is inside the pygame folder
pygame > Include, Lib
Include > pygame > (many hh files)
Lib > SitePackages > pygame > init (I know that it has the attribute init)
Since there is '3' pygame folder, is this causing the error for my program?
import pygame, sys
pygame.init()
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Hello World!')
while True: # main game loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…