2014-06-16 28 views
0

創建可執行文件我已經創建了一個Python應用程序,並使其可執行使用cx_Freeze CMD控制檯。啓動由cx_Freeze在Python

當腳本未轉換到它用於拍攝從cmd的輸入(在視窗)的可執行文件。但是,當它被轉換成exe時,它不會提示我輸入。

我用下面的代碼爲setup.py我的腳本。

includefiles = ["checkPointValueSheets.py"] # include any files here that you wish 
includes = [] 
excludes = [] 
packages = ["lxml"] 

exe = Executable(
# what to build 
    script = "app.py", # the name of your main python script goes here 
    initScript = None, 
    base = None, # if creating a GUI instead of a console app, type "Win32GUI" 
    targetName = "aflPredictionAutomation.exe", # this is the name of the executable file 
    copyDependentFiles = True, 
    compress = True, 
    appendScriptToExe = True, 
    appendScriptToLibrary = True, 
    icon = None # if you want to use an icon file, specify the file name here 
) 

setup(
# the actual setup & the definition of other misc. info 
    name = "app", # program name 
    version = "0.1", 
    description = 'A general enhancement utility', 
    author = "K Perkins", 
    author_email = "", 
    options = {"build_exe": {"excludes":excludes,"packages":packages, 
     "include_files":includefiles}}, 
    executables = [exe] 
) 

請幫我啓動CMD控制檯,我打我的EXE輸入。

運行可執行文件,當我得到這個錯誤..

enter image description here

感謝

回答

2

這是媒體鏈接在你的代碼中的註釋(在cx_Freeze’s documentation,你應該簡單地發表意見2線

if sys.platform == "win32": 
    base = "Win32GUI" 

如果你讓你的base = None exe將是一個控制檯應用程序(而不是GUI一個),如果沒有從一個控制檯啓動,Windows將自動提供一個新的控制檯。

+0

我評論過的線條和編輯我的問題太代碼。其實錯誤屏幕快照是因爲它不能'輸入名稱_elementpath' 它來自於我的源代碼中的行 'import lxm.html' 。你能幫我嗎?腳本在cmd上運行良好。 – Anand

+1

這是一個完全不同的問題:你必須告訴cx_freeze你使用的模塊。你可以看看這篇文章[http://stackoverflow.com/questions/16639429/cx-freeze-module-dependency](http://stackoverflow.com/questions/16639429/cx-freeze - 模塊依賴關係) –

+0

該頁面沒有任何內容 – Anand