1

I'm trying to make a game using pygame and pygame_menu. When I try to install pygame_menu I get this error:

Traceback (most recent call last):
  File "D:\Game\main.py", line 7, in <module>
    import pygame_menu
ModuleNotFoundError: No module named 'pygame_menu'

I ran this command to install the module: pip install pygame-menu -U

Here's how I import the module: import pygame_menu

I have no idea how to fix this. If you know how to fix this or a better module for GUI elements in pygame please tell me.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
ProGamer2711
  • 451
  • 1
  • 5
  • 18

2 Answers2

-2

I'm far from experienced in PyGame and pygame-menu, but I'm able to get a window up and running with the following code and importing both pygame and pygame-menu with the following commands:

pip install pygame

pip install pygame-menu -U

import pygame
import pygame_menu

pygame.init()
surface = pygame.display.set_mode((600, 400))

menu = pygame_menu.Menu('Welcome', 400, 300,
                   theme=pygame_menu.themes.THEME_BLUE)

menu.add.label('Hello World!')

menu.mainloop(surface)

Please try this code above to see if you can get it working.

Julia Meshcheryakova
  • 3,162
  • 3
  • 22
  • 42
-2

Install instructions

These are the install instructions. Follow these to install pygame-menu. Once you've done that, import by using import pygame_menu