Importing Pygame

Viewed 447

I have installed pip and pygame module a few hours ago and when i try to import pygame module in my python

import pygame
print("well")

file i get this error

'''

Traceback (most recent call last):
  File "f:/VSCode/Alien_Invasion/alien_invasion.py", line 2, in <module>
    from pygame import *
  File "C:\Users\3mosh\AppData\Roaming\Python\Python37\site-packages\pygame\__init__.py", line 130, in <module>
    from pygame.base import *
ModuleNotFoundError: No module named 'pygame.base'

'''

3 Answers

Uninstall pygame before attempting each install with pip3 uninstall pygame.

Try using pip3 install pygame

if that doesn't work, try pip install pygame-menu==2.0.1

Also, if you have python installed multiple times, it could be installed on one of those.

If you are using Pycharm, go to File --> Settings --> Project settings --> Python interpreter. Here you can choose whatever package you want, then just click apply and it should work. I had the same problem, for me this worked.

You could use an interpreter with pygame built in (mu), which should work out of the box.

Related