1

First of all i'm on windows and i'm trying to convert my python programm to an executable. My Programm is a console based music player. I'm using the pygame mixer to play my mp3 files. I converted it to an executable using auto-py-to-exe.

As .py in PyCharm, the programm worked perfectly fine, but when I start the .exe it immediately crashed.

In the PowerShell i get this error message:

pygame 2.0.0.dev6 (SDL 2.0.10, python 3.8.2)
Hello from the pygame community. https://www.pygame.org/contribute.html\ Traceback (most recent call last):
File "MPMbeta.py", line 569, in module
File "MPMbeta.py", line 550, in load_settings
File "MPMbeta.py", line 46, in set_song
pygame.error: Failed loading libmpg123-0.dll:
[10464] Failed to execute script MPMbeta

So the function that crashed the programm was:

def set_song(self, name):
    self.name = name
    pygame.mixer.pre_init(44100, -16, 2, 2048)
    self.mixer.load(Player.path + name)
    self.mixer.play(1)
    self.mixer.set_volume(self.volume)
    self.current_song_len = int(MP3(Player.path + name).info.length) * 1000

That's why i think the pygame mixer crashed the programm. Pygame itself worked fine as the "Hello from the pygame community." indicates.

So my question is why does the pygame mixer has no problem loading libmpg123-0.dll when in PyCharm but as .exe? And how can i resolve that issue?

Ladekabel3
  • 11
  • 2
  • `Python` wasn't created to create `.exe` files so it doesn't work perfectly. Tools like `pyinstaller` try to find all elements needed to run it but often they have problem with C/C++ libraries which are used by Python directly or by other C/C++ libraries. Tools like `pyinstaller` try to get all in one folder and compress with zip to selfextracting .exe file - and if it doesn't get all needed libraries in folder then .exe has problem to find them. `pyinstaller` should have page which describe what to do when it doesn't work - you may have to manually add missing libraries to configuration. – furas Aug 12 '20 at 02:36
  • So I have tried for a bit and I found out that the problem is also with the .py. It only works in PyCharm. If I try to txecute the .py outside of an IDE I get the same error. I can't find a solution to that. All suggestions I found were "try restart your PC" or "try reinstall pygame" but nothing worked. One suggestion was downloading the libmpg123-0.dll file manualy and put it in the system32 folder but that didn't work as well. I'm clueless. – Ladekabel3 Aug 12 '20 at 17:08
  • better find `libmpg123-0.dll` on disk and put it in folder with your script. And later you have to add to settings in `auto-py-to-exe` so it will also add `libmpg123-0.dll` to exe file. – furas Aug 12 '20 at 18:21
  • Update: I have partly figured it out. I had a problem with the Python version i was using. Pygame seems to dislike python3.8.5. PyCharm was using Python3.8.2 so i installed python 3.8.2 on my machine and at least the .py works now – Ladekabel3 Aug 12 '20 at 19:22

0 Answers0