0

我正在使用 GUI2Exe 将我的 python/pygame 游戏编译为 .exe

我的字体模块有问题。

在 GUI2Exe 中使用 python 2.7 和 py2exe 选项我已经用 2.7 版本更新了 python、pygame 和 py2exe。我的程序运行良好,但是在我用 py2exe 编译它之后,我得到了这个。

这是我得到的错误:

Fatal Python error: (pygame parachute) Segmentation Fault

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

我的游戏从控制台开始,然后运行该部分。但是一旦显示开始,我就会崩溃。

谢谢

4

2 回答 2

1

Had similar problems and that one too. Found a way to solve them:

After few weeks (had this problem even before) I'm happy to say that I solved this problem! :)

1st part of my problem (http://i.stack.imgur.com/WpkjR.png): I solved it by editing setup.py script with adding "excludes" part in it. That resulted in successful making of executable file!

Modified setup.py script:

from distutils.core import setup
import py2exe
setup(windows=['source_static.py'], options={
          "py2exe": {
              "excludes": ["OpenGL.GL", "Numeric", "copyreg", "itertools.imap", "numpy", "pkg_resources", "queue", "winreg", "pygame.SRCALPHA", "pygame.sdlmain_osx"],
              }
          }
      )

So, if you have similar issues, just put those "missing" modules into this "excludes" line.

2nd part:

After I succeeded in making of executable file, I had next problem: "The application has requested the Runtime to terminate it in unusual way. Please contact...". After days and days of searching and thinking how to solve this another problem, I found a way to do it. I couldn't believe that the problem was so absurd. The problem was in my code, with font definition:

font1 = pygame.font.SysFont(None, 13)

After changing "None" to some system font name (for an example "Arial" (must be a string)), and compiling, I couldn't believe that my .exe file worked!

font1 = pygame.font.SysFont("Arial", 13)

Of course, you can use your own font, but you must specify its path and define it in your program.

So for all of you who are experiencing this issues, try this steps and I hope that you will succeed. I really hope that this will help you, because I've lost days and weeks trying to solve these problems. I even tried making my .exe file with all versions of python and pygame, with many other .exe builders and setup scripts, but without luck. Besides these problems, I had many other problems before but I found answers to them on stackoverflow.com.

I'm happy that I found a way to solve this problems and to help you if you are faced with the same ones.

Small tips (things I've also done):

1st: update your Microsoft Visual C++ library to the latest one.

2nd: if you have images or fonts similar that your executable program needs, include them to dist folder (where your .exe file has been created).

3rd: when you are making your .exe file, include all needed files to the folder where your setup.py script is (all files and directories that your main script uses).

Used Python 2.7 x64, pygame and py2exe.

于 2013-03-05T05:06:38.663 回答
0

不要使用 gui2exe 使用此链接中的此文件:http: //pygame.org/wiki/Pygame2exe

按照说明操作并根据需要修改文件。将文件放在与“游戏”主目录相同的目录中,然后从控制台运行文件。

于 2012-06-27T23:38:56.383 回答