How to import pygame.locals successfully

Hi Stackoverflowers,

I am learning how to program with Pygame and I am trying to import pygame.locals According to the training course I am studying, I am starting as such;

import pygame, sys
from pygame.locals import *

      

I am getting this error message:

Traceback (last call last): File "C: /Python33/test.py", line 2, from pygame.locals import * ImportError: no module named "pygame.locals"

I downloaded Pygame (binary package) for Python 3.2 and I am currently running 3.3. When I'm import pygame

in the Python shell, no error is returned and so I believe Pygame was installed successfully. I am running Windows 7 64 bit.

I've seen a similar post regarding pygame.locals and Raspberry Pi and Linux, so I believe this post is still relevant. Let me know if this is not the case.

0


source to share


3 answers


I am assuming you have a file named pygame.py in the current directory where you are using the script.



+6


source


I found that on Windows 7 64-bit, you need to get Python 3.3.5 as well as pygame-1.9.2a0 -hg version from Bitbucket .

This solved the problem ImportError: No module named 'pygame.locals'

for me.



(It's kind of weird that the pygame site doesn't have the latest pygame versions.)

0


source


yes @Bartlomiej Lewandowski you were right. I also faced the same problem and came here to resolve this issue. I did not download the newest version as apt-get install reported it was the newest version.

I just renamed my pygame.py file to a different random name. It is working fine now. So the problem was that we named our file as pygame.py, which is limited in the pygame module , I'm not sure. But now it works great.

Thanks again to Bartlomey Lewandowski.

0


source







All Articles