Python - Pygame Error When Executing Exe File

Pygame executable not working on another PC

2 possible errors:

1. You forgot to place a file in the .zip

You should use PyInstaller instead of cx_Freeze: you just need to type one line of code in the command prompt, you don't need any other file, and you have the possibility to convert your .py/.pyw file into only one .exe file, without a whole bunch of other files.

This way you can't miss any file in the .zip.



2. You are on win64 and you are sending the program to a win32 computer (or vice versa)

To avoid that issue, you can either:

  1. Reinstall the win32 version of Python
  2. Convert your file to .exe from a win32 computer.

Links to related answers: 1 and 2

Failed to execute script error after successful execution exe

I figured it out!! All I needed to do was change exit() to sys.exit() (and add import sys as well).

No module named pygame on a python to exe file

pip install pygame is the command you are looking for.

Run this command in your terminal and then try again.



Related Topics



Leave a reply



Submit