Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python doesn't find pygame.locals

Tags:

python

pygame

I have sucessfully installed pygame on my Windows 10 computer, using Python3.6, here's my code :

import pygame
from pygame.locals import *

pygame.init()
window = pygame.display.set_mode((800,600))

Python says the following :

Traceback (most recent call last):
  File "C:/Users/Yann/AppData/Local/Programs/Python/Python36-32/Files/ProjetASINFO/lolol.py", line 2, in <module>
    from pygame.locals import *
ModuleNotFoundError: No module named 'pygame.locals'

Have you any ideas about what could happen ? (My file isn't named pygame.py).

like image 752
Tolemack Avatar asked May 24 '26 01:05

Tolemack


1 Answers

As the comments stated, you might've installed a different old version of pygame, you will need to delete the old one and install the newest version from here and choose pygame‑1.9.3‑cp36‑cp36m‑win32.whl: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

If it still does not work, check over your files and see if there's another pygame.py somewhere else in your $PATH. Also, check out this post as it contains similar questions to yours.

like image 70
Taku Avatar answered May 26 '26 15:05

Taku



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!