Skip to content Skip to sidebar Skip to footer

Pygame Installation, No Module Named Pygame.base

I am trying to install pygame with the powershell from VS 2019 with python 3.8, I use python3 -m pip install -U pygame --user and it installs pygmae just fine but when I try to run

Solution 1:

jm96:

  1. Check if pygame is in pip3 list:
$ -> pip3 list --format=columns | grep -i pygame
pygame                       1.9.6

It it doesn't, install it:

$ -> python3 -m pip install pygame

Note: Keep in mind the following (you have used the user parameter):

$ -> man -P cat pip3 | grep -i '\--user'--user Install using the user scheme.

What is the purpose of "pip install --user ..."?

$ ->  pip3 list --format=columns --user | grep -i pygame
pygame            1.9.6
  1. Check the imported module. You use from pygame.base import *. Change it to from pygame import base. You can do from pygame import * but if you don't need all modules is no necessary.
$ -> cat pygame_import.py 
from pygame import base 
import sys

module = 'pygame.base'if module in sys.modules:
    print("OK")
else:
    print("KO")

$ -> python3 pygame_import.py 
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
OK

Post a Comment for "Pygame Installation, No Module Named Pygame.base"