I should probably make this clear from the offset: I know this is a common error, and I've been reading up on several other questions asked along the same lines, but the solution to all of them seems to be, 'you have some other file called 'pygame.py', you need to rename it'. That doesn't work for me because I am absolutely positive that I have no other files on my computer named pygame other than the one installed in my site packages. This is the code I am trying to run:
import pygame
pygame.init()
and this is the error message I get:
Traceback (most recent call last):
File "C:\Python34\Games\Race.py", line 2, in <module>
pygame.init()
AttributeError: 'module' object has no attribute 'init'
I even ran pygame.__path__
to make sure it wasn't confused with some other file named pygame, but it returned
NamespacePath(['C:\\Python34\\lib\\site-packages\\pygame'])
meaning it definitely has the right file, but for some reason it still won't work.
EDIT: Two days later I still have no idea what's going on, I've uninstalled and reinstalled pygame several times, still got squat.
I've been having this same issue and just got it resolved. I have python3 and downloaded pygame 1.9.2 according to the instructions here. These commands download a directory called pygame in which another directory by the same name is embedded; the embedded one is the one you want import. Move it outside of the top directory of what is downloaded.