如何使用pygame构建Python 3.4.3源代码以执行exe?
问题描述:
你好我该如何构建python 3.4.3 pygame库的源代码到exe文件(独立)? (py2exe,不起作用。)有什么建议?谢谢如何使用pygame构建Python 3.4.3源代码以执行exe?
答
关于您的评论似乎你的设置有问题。你必须告诉py2exe包含什么。
有一个有用的解释如何得到一个独立的EXE,以及如何管理包括:http://pythontips.com/2014/03/03/using-py2exe-the-right-way/
本网站中的总例子如下所示:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
DATA=[('imageformats',['C:\\Python27/Lib/site-packages/PyQt4/plugins/imageformats/qjpeg4.dll',
'C:\\Python27/Lib/site-packages/PyQt4/plugins/imageformats/qgif4.dll',
'C:\\Python27/Lib/site-packages/PyQt4/plugins/imageformats/qico4.dll',
'C:\\Python27/Lib/site-packages/PyQt4/plugins/imageformats/qmng4.dll',
'C:\\Python27/Lib/site-packages/PyQt4/plugins/imageformats/qsvg4.dll',
'C:\\Python27/Lib/site-packages/PyQt4/plugins/imageformats/qtiff4.dll'
])]
setup(
options = {'py2exe': {'bundle_files': 1, 'compressed': True,"includes":["sip"]}},
windows = [{'script': "main.py"}],
zipfile = None,
data_files = DATA,
)
,你必须调用
python setup.py py2exe
让你的独立exe文件。
我建议对您的问题给出更详细的解释。你的项目结构如何?你如何使用py2exe?有没有错误信息? – siebenschlaefer
我有3个类打破了文件,我导入它们。当我使用py2exe时,它不会生成我导入的类。所以当我运行exe文件时,它崩溃了。有什么建议么? – Poom1997
你在哪里包含它们?你的py2exe设置如何?请提供您的信息来获得有用的答案。 – siebenschlaefer