0

I am having the same (or very similar) issue, as here (Importing Pygame, ModuleNotFoundError: No module named 'pygame.base') but the recommendations didn't help me.

I had to wipe my Windows machine 2 days ago, so I reinstalled Python 3.9 (from python.org), and installed pygame without any problems.

When I try to import pygame at the beginning of a file, my error looks like this:

Traceback (most recent call last):
  File "c:\g\code\snakegame\py\snakegame.py", line 1, in <module>
    import pygame
  File "C:\Program Files\Python39\lib\site-packages\pygame\__init__.py", line 90, in <module>
    from pygame.base import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
ModuleNotFoundError: No module named 'pygame.base'

If I try running the following, as recommended on (Pygame installation, no module named pygame.base)

from pygame import base
import sys

module = 'pygame.base'

if module in sys.modules:
    print("OK")
else:
    print("KO")

I get...

Traceback (most recent call last):
  File "c:\g\code\snakegame\py\pygame_import.py", line 1, in <module>
    from pygame import base
  File "C:\Program Files\Python39\lib\site-packages\pygame\__init__.py", line 90, in <module>
    from pygame.base import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]   
ModuleNotFoundError: No module named 'pygame.base'

I tried uninstalling and reinstalling pygame.

python -m pip uninstall pygame
python -m pip install -U pygame

I tried reinstalling python. I tried python from python.org, the python app from the windows store, and I also tried installing pycharm via the jetbrains toolbox.

I tried uninstalling pygame and installing pygame-2.0.0-cp39-cp39-win32.whl manually. The .whl was pulled from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

I checked and there does exist this .pyd... C:\Program Files\Python39\Lib\site-packages\pygame\base.cp39-win32.pyd

I checked for related issues on https://github.com/pygame/pygame/issues

Anyone have any ideas?

C-137
  • 1
  • 1

1 Answers1

-2

Pygame isn't compatible with Python 3.9 ON WINDOWS at the moment. In fact a lot of packages aren't. Pygame is compatible with Python 3.7 on windows, so you are gonna have to install python 3.7.7 or earlier.

Ayaan
  • 157
  • 1
  • 11
  • 1
    That's just not true. Pygame works fine with Python 3.9. – sloth Nov 20 '20 at 09:18
  • Nah it actually doesn't on windows. I know on mac and linux it does, but on the pygame docs it literally says "Notice that this does not seem to work with Python 3.9 - use 3.7." Pygame said you need Python 3.7 for windows. – Ayaan Nov 20 '20 at 13:00
  • It works fine for me on Windows and Python 3.8.5 but I tried to install Pygame with PyPI in Python 3.9 and it didn't work (same error as @c-137) – D_00 Nov 20 '20 at 17:13
  • Yeah it don't work in python 3.9 on windows, windows always behind lol. – Ayaan Nov 20 '20 at 20:17
  • Pygame 2.0 works fine on Python 3.9 for Windows: All tests pass. See https://ci.appveyor.com/project/pygame/pygame/builds/36010824/job/potpl3dwc7jnv1nk – cgohlke Nov 20 '20 at 23:13
  • Huh, that's weird, it says on the pygame website it doesn't.... – Ayaan Nov 20 '20 at 23:40