0

Below is the error I am receiving and the code I have written. I know similar questions have been asked , but the solutions they are given do not relate to this case. And I can't seem to figure out why I am receiving this attribute error. I am running python 3.3 and pygame. The OS im on is ubuntu 12.10. I hope someone can find a solution to this problem so I can continue working on this physics simulation.

Traceback (most recent call last):
  File "/media/lawton/D4B1-5B96/programming/Python/gamephysics.py", line 9, in <module>
    screen = pygame.display.set_mode((width, height))
AttributeError: 'module' object has no attribute 'display'
import pygame


background_colour = (255,255,255)

(width, height) = (300, 200)

screen = pygame.display.set_mode((width, height))

pygame.display.set_caption('Tutorial 1')

screen.fill(background_colour)

pygame.display.flip()

running = True
while running:
  for event in pygame.event.get():
    if event.type == pygame.QUIT():
      running = False
1
  • 2
    Just to be certain; what does print(pygame.__file__) print (after importing it, before using pygame.display)? Commented May 19, 2013 at 19:42

1 Answer 1

2

You are shadowing the pygame library with another pygame.py file, probably in the same location as gamephysics.py.

Print out the file path of the offending module:

import pygame

print('Path to pygame module:', pygame.__file__)

This will you show you where the 'rogue' module is located. Once you find it, rename it to something else.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.