PYGame - ImportError: No module named locals Raspberry Pi

前端 未结 2 1125
说谎
说谎 2021-01-07 12:52

I have the following code:

 #!/usr/bin/python
 # -*- coding: iso-8859-15 -*-

 import pygame, random
 from pygame.locals import *
 pygame.init()
 clock = pyg         


        
2条回答
  •  抹茶落季
    2021-01-07 13:09

    Your problem is that you have a file that is named pygame.py, or a bytecode left-over from such a file named pygame.pyc.


    Calling import pygame works, but it will not import pygame, but the that very file.

    And since your file can't find a module named locals in that file, the error is raised.

    So, just rename your file to anything other than pygame.py or other modules you want to import, or, if there's a pygame.pyc bytecode file, remove that.

提交回复
热议问题