GoldMamba
GoldMamba

Reputation: 21

AttributeError: module 'pygame.display' has no attribute 'setmode'

I have the following error:

AttributeError: module 'pygame.display' has no attribute 'setmode'

Code:

import sys
import pygame

def run_game():
    pygame.init()
    screen = pygame.display.setmode((1200,800))

run_game()

I already verified the following:

  1. Latest Python and Pygame version installed
  2. My file name is not pygame and I don't have any "pygame.py" file created in my entire PC
  3. Pygame is installed under C:\Users\XXX\AppData\Local\Programs\Python\Python38\Lib\site-packages
  4. Reinstalling Pygame via command
  5. Opened the test-game "py -m pygame.examples.aliens" in command succesfully to see if Pygame ran good
  6. Saved my file under the Pygame package
  7. print(pygame.version) print(sys.version) : Both show valid address and latest version

What could be happening? I don't know what else I can do. I am using Windows

Upvotes: 0

Views: 1905

Answers (1)

Barış Akın
Barış Akın

Reputation: 147

Try instead pygame.display.set_mode().

You have forgotten "_" between "set" and "mode"

import sys
import pygame

def run_game():
    pygame.init()
    screen = pygame.display.set_mode((1200,800))

run_game()

correct syntax!

Upvotes: 1

Related Questions