Py2Exe将无法在Python 3上成功编译pygame.font模块 [英] Py2Exe won't successfully compile the pygame.font module on Python 3

查看:1431
本文介绍了Py2Exe将无法在Python 3上成功编译pygame.font模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个程序使用pygame模块在Python 3和它的工作正常在python,但当我尝试编译是使用py2exe它不会运行。 (我只是得到programName.exe尝试运行它时停止工作错误)。



我设法缩小这个问题到pygame.font模块,当我注释所有使用该模块的行一切工作正常。我试图强制包含模块使用-i标志在py2exe,但它似乎没有改变任何东西...



我做了什么错误? / p>

编辑:我设法得到程序不工作的原因 - 它崩溃,因为它找不到build\executable.exe\pygame\freesansbold.ttf。我不明白是为什么地狱是pygame文件夹应该位于一个文件夹中的可执行文件的名称。 (当然,我不能创建一个与目录中现有文件同名的文件夹)。如果任何人有一个线索如何解决它,请帮助!!

解决方案

我有同样的问题使用cx_Freeze,这将为你工作以及。打开你的pygame包文件夹。它应该是 C:\Python34\Lib\site-packages\pygame 。应该有一个名为freesansbold.ttf的True Type字体文件。复制该文件,然后打开包含您的exe程序的文件夹。应该有一个名为library的压缩文件。打开它,去到压缩文件中的pygame文件夹。应该看起来像这样 \build\exe.win32-3.4\library.zip\pygame 。只需粘贴freesansbold.ttf文件在该文件夹,它应该完美地工作。


I made a program using the pygame module on Python 3 and it works fine within python, but when I try to compile is using py2exe it won't run. (I just get the programName.exe has stopped working error upon trying to run it).

I managed to narrow down this problem to the pygame.font module as when I comment all the lines that use that module everything works fine. I tried to forcefully include the module using the -i flag in py2exe, but it doesn't appear to change anything...

What am I doing terribly wrong?

Edit: I managed to get the reason of the program not working - it crashes as it can not find build\executable.exe\pygame\freesansbold.ttf . What I don't understand is why the hell is the pygame folder supposed to be located in a folder with the name of my executable? (Of course, I can not create a folder with the same name as an existing file in the directory). If anyone has a clue to how to fix it, please help!!

解决方案

I had the same problem using cx_Freeze, so hopefully this will work for you as well. Open up your pygame package folder. It should be C:\Python34\Lib\site-packages\pygame. There should be a True Type Font File titled freesansbold.ttf. Copy that file then open the folder containing your exe program. There should be a zipped file called library. Open it up and go to the pygame folder inside the zipped file. Should look something like this \build\exe.win32-3.4\library.zip\pygame. And just paste the freesansbold.ttf file in that folder and it should work perfectly.

这篇关于Py2Exe将无法在Python 3上成功编译pygame.font模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆