Reputation: 427
I am using pygame 1.9.2pre with python3. When I run idle3 and type
>>> import pygame
>>> pygame.init()
this works perfectly however when I write these two lines in a .py file and then run it in idle3 (by opening it and hitting F5) I get this messege
Traceback (most recent call last):
File "/home/nabeel/Devalopment/Python/pygame.py", line 6, in <module>
import pygame
File "/home/nabeel/Devalopment/Python/pygame.py", line 9, in <module>
pygame.init()
AttributeError: 'module' object has no attribute 'init'
Upvotes: 0
Views: 180
Reputation: 32189
Name your file something different from pygame.py
otherwise your program will default to importing your own file and obviously that is not what you want since you want the other module.
You can use print(pygame.__path__)
to check where it is that you are actually getting your pygame module
from and in your case it would point to the directory you are currently in.
Upvotes: 2