0
import os, sys

import pygame
from pygame.locals import *

if not pygame.font: print 'Warning, fonts disabled'
if not pygame.mixer: print 'Warning, sound disabled'

this is the code I tried but this shows these errors

File "D:/Python/sample codes/pygame.py", line 2, in <module> import pygame   
File "D:/Python/sample codes\pygame.py", line 3, in <module> from pygame.locals import * ImportError: No module named locals
KittMedia
  • 7,368
  • 13
  • 34
  • 38

2 Answers2

0

A.) Have you checked if your version of python corresponds to your version of pygame, or if your version of pygame is 64 or 32 bit(so that it is the same as your computer)

B.) Try to install it again, maybe using the installer again or you could use pip install.

This might help:

(Unable to install Pygame using pip)

The problem here is that the pygame module locals is not installed properly, or at all, so pygame has been installed, but not properly so you must install it again.

Community
  • 1
  • 1
ModoUnreal
  • 642
  • 5
  • 15
0

Not sure if this helps too much, but I had problems installing pygame. I tend to write code using PyScripter which is a great, easy tool to use. After lots of issues trying to install pygame, however, I downloaded the 2.7 version (which is available free on their website with all other versions) which came with pygame already installed into the scripter and all modules work perfectly. Maybe this would help!