Importing assets in Python doesn't work after making a build

16 Views Asked by At

So I used this code here below to import a sound to my PyGame project, and while normaly it works alright, whenever I make a build and run it, that "current path" seemingly changes to something completely different. What can I change to make it work properly?

current_file_path = os.path.realpath(__file__)
current_directory = os.path.dirname(current_file_path)
buttonSound = pygame.mixer.Sound(os.path.join(current_directory, "assets\\button.wav"))

Only thing that came to my mind is to check what is that new "current path". Apparently it changes to 'C:\Users[My Username]\AppData\Local\Temp_MEI44802' with the last folder not even being there, for some reason

0

There are 0 best solutions below