2015-10-17 31 views
0

你好我該如何構建python 3.4.3 pygame庫的源代碼到exe文件(獨立)? (py2exe,不起作用。)有什麼建議?謝謝如何使用pygame構建Python 3.4.3源代碼以執行exe?

+0

我建議對您的問題給出更詳細的解釋。你的項目結構如何?你如何使用py2exe?有沒有錯誤信息? – siebenschlaefer

+0

我有3個類打破了文件,我導入它們。當我使用py2exe時,它不會生成我導入的類。所以當我運行exe文件時,它崩潰了。有什麼建議麼? – Poom1997

+0

你在哪裏包含它們?你的py2exe設置如何?請提供您的信息來獲得有用的答案。 – siebenschlaefer

回答

1

關於您的評論似乎你的設置有問題。你必須告訴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文件。