How to import pygame.locals successfully

后端 未结 4 1100
[愿得一人]
[愿得一人] 2021-01-17 01:21

Hello there Stackoverflowers,

I am learning how to program with Pygame and I am trying to import pygame.locals According to the tutorial I am learning from, I am sta

相关标签:
4条回答
  • 2021-01-17 01:55

    My guess is that you have a file named pygame.py in the current directory in which you are running you script.

    0 讨论(0)
  • 2021-01-17 01:55

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

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

    (Somehow it's a bit weird that the pygame website doesn't provide latest versions of pygame.)

    0 讨论(0)
  • 2021-01-17 02:10

    For RedHat I needed to install yum install SDL-devel-1.2.14-7.el6_7.1.x86_64

    0 讨论(0)
  • 2021-01-17 02:13

    yes @Bartlomiej Lewandowski, you were right.I also faced the same problem and came here to resolve it. I did not download any newer version as apt-get install was giving the message that this is the newest version.

    I just renamed my file pygame.py to some other random name. It is working fine now. So the problem was we named our file as pygame.py, Which is restricted in pygame module, I am not sure. But its working fine now.

    Thanks Bartlomiej Lewandowski once again.

    0 讨论(0)
提交回复
热议问题