So I just came up with a problem that i don't understand. I have two python files one is for the separate game menu, and second for the game. The menu is written with tkinter and the problem comes when I click( in my menu ) 'Start game' button. It destroys menu, but does not open another file - game. Here's the code from menu where the problem occurs.
root.destroy()
os.system('main.py')
That's what console says:
Traceback (most recent call last):
File "main.py", line 8, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
Initial code from the second file (game file)
from backdoor import *
import pygame
from Config import *
pygame.init()
When I start only the game file it works as it should - there's no Errors, that's why i have no idea why this problem occurs. I'm new to coding so would appreciate any help and explanations.
CodePudding user response:
To import pygame you must have it installed:
pip3 install pygame
If you have it already installed try to reinstall
pip3 uninstall pygame
pip3 install pygame
CodePudding user response:
Found the solution, so the problem was my sillnes and a lack of knowledge. I was using Anaconda environment and I've installed pygame with navigator cmd, so i thought that it's installed. I've reinstalled Python and added pip path in cmd with setx PATH "%PATH%;path", then I could actually install pygame and now everything works properly. Thanks for help!
