Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Machine Learning by (19k points)

I have been getting this error while trying to make a game using pygame.

ImportError: No module named pygame.locals

This thread says that I need to install that module. And I followed those and steps and installed it. In fact, I even got an installation success message. But when I try to run the code again, I still get the same error.

What is the issue?

1 Answer

0 votes
by (33.1k points)

You should import the module first and then use it. Change the first two lines. 

import pygame

from pygame.locals import *

This would help to remove the error. Since Pygame is a part of  Machine Learning, understanding it will give you a stronghold of the domain.

Hope this answer helps you!

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...