Cant Find Pygame Module
I just started game developing in python with pygame and I have the following code: bif='main_background.jpg' mif='player_head.png' import pygame, sys from pygame.locals import *
Solution 1:
I'm about 83.4% sure that you named your script pygame.py
(or possibly created another file with the same name in the same directory as your script).
If you do that, Python has no way of knowing what you want to load when you import pygame
. It could be your script, it could be the installed package—they both have the same name.
What ends up happening is that import pygame
imports your script, then from pygame.locals import *
looks for a module called locals
inside your script. Since your script is a script, and not a package, Python just gets confused and prints a confusing ImportError
.
Python 3.x gives you some ways around this, but 2.x does not, and I'm guessing you're using 2.x.
So, the solution is:
- Rename your script to
mygame.py
. - Delete any other files in the same directory as your script named
pygame.py
.
Post a Comment for "Cant Find Pygame Module"