Pyinstallet可能幫助下發布...
但py2exe並不複雜...
看看這個py2exe樣本設置(從這裏開始,但它是意大利,所以我把它翻譯http://bancaldo.wordpress.com/2010/05/13/python-py2exe-setup-py-sample/)
#!/usr/bin/python
from distutils.core import setup
import py2exe, sys, wx, os
# Se eseguito senza argomenti, crea l'exe in quiet mode.
# If executed without args, it makes the exe in quiet mode
if len(sys.argv) == 1:
sys.argv.append("py2exe")
sys.argv.append("-q")
class FileBrowser(wx.FileDialog):
def __init__(self):
wildcard = "Python files (*.py)|*.py|" \
"Tutti i files (*.*)|*.*"
dialog = wx.FileDialog(None, "Choose the file", os.getcwd(),
"", wildcard, wx.OPEN)
if dialog.ShowModal() == wx.ID_OK:
print(dialog.GetPath())
self.file = dialog.GetPath()
self.fin = open(self.file, 'r')
dialog.Destroy()
class Target:
def __init__(self, **kw):
self.__dict__.update(kw)
# info di versione
self.version = "1.0.0"
self.company_name = "Bancaldo TM"
self.copyright = "no copyright"
self.name = "py2exe sample files"
manifest_template = '''
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity
type='win32'
name='Microsoft.VC90.CRT'
version='9.0.21022.8'
processorArchitecture='*'
publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*" />
</dependentAssembly>
</dependency>
</assembly>
'''
# File Browser
app = wx.PySimpleApp()
fb = FileBrowser()
# Assegno il nome all'eseguibile di uscita
# Give the name at the exe file being created
textentry = wx.TextEntryDialog(None, "name file EXE?",'','')
if textentry.ShowModal() == wx.ID_OK:
destname = textentry.GetValue()
RT_MANIFEST = 24
test_wx = Target(
description = "A GUI app",
script = fb.file, # programma sorgente dal quale creiamo l'exe
# source from wich we create the exe
other_resources = [(RT_MANIFEST, 1, manifest_template % dict(prog="tried"))],
icon_resources = [(1, "py.ico")],
# dest_base = "prova_banco") # Nome file di destinazione
#Name Destination file
dest_base = destname) # Nome file di destinazione
setup(
data_files=["py.ico"],
options = {"py2exe": {"compressed": 1,
"optimize": 2,
"ascii": 1,
"bundle_files": 1}},
zipfile = None,
windows = [test_wx],
)
也inclused上選擇文件小的圖形界面至極幫助你;)
編輯:
這是一個簡單的樣本,也許這是更爲有用:)
from distutils.core import setup
import py2exe
setup(
name = 'AppPyName',
description = 'Python-based App',
version = '1.0',
windows = [{'script': 'Main.pyw'}],
options = {'py2exe': {'bundle_files': 1,'packages':'encodings','includes': 'cairo, pango, pangocairo, atk, gobject',}},
data_files=[ 'gui.glade',]
zipfile = None,
)
教程一步一步:
1 - 創建一個.py文件,將其命名,例如「 hello.py「還沒有一個GUI 2-做出setup.py文件
from distutils.core import setup
import py2exe
setup(console=['hello.py'])
通知使用‘’而不是‘Windows控制檯’,」因爲你沒有一個GUI
然後,移動你的hello.py文件和你的設置。Python目錄中的py文件;然後打開cmd,然後一旦你在正確的目錄(通常是C:\ python2x)到貨,型號:
python setup.py py2exe
你是exe文件將在dist目錄。如果某些.dll文件丟失,只需下載它並放入python目錄即可。
一旦你的程序會更復雜,可能需要其他指令;看看我發佈的其他2個setup.py樣本。 希望這幫助
已經有兩個人知道主要選項。你問的是錯誤的問題,你應該(1)告訴我們**什麼**不能與cx_Freeze一起工作,所以我們可以幫助解決它或(2)尋求幫助來開始使用py2exe。此外,你期望太多(「只選擇文件和輸出」 - 很多非平凡程序都有依賴關係,程序無法靜態檢測)。 – delnan 2010-12-11 15:06:23
確定你可能是對的那部分,當我打開cx_freeze它沒有做任何事情,它只是一個非常小的批處理文件..我真的不知道它是如何編譯任何東西的...另外,我想知道到底是什麼鍵入如果我編譯「test.py」並輸出.exe文件到「F:\ scripts \ python」 – daniel11 2010-12-11 15:10:52
py2exe非常簡單。這不是「太複雜」,除非你的設置很複雜,但你沒有說什麼會讓它變得複雜。 – 2010-12-11 15:11:57