2014-04-01 61 views
1

我使用Python 3.3.3錯誤轉換的.py爲可執行使用cx_freeze

在我send_email.py文件下面是我setup.py代碼

import sys 
from cx_Freeze import setup, Executable 


build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]} 

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

setup( name = "send_email", 
     version = "0.1", 
     description = "send the email", 
     options = {"build_exe": build_exe_options}, 
     executables = [Executable("send_email.py", icon="icon.ico", base=base)]) 

唯一導入的smtplib。

以下錯誤消息是我收到的命令窗口中創建可執行文件時:

c:\Python33>python.exe setup.py build 
running build 
running build_exe 
copying c:\Python33\lib\site-packages\cx_Freeze\bases\Win32GUI.exe -> build\exe. 
win-amd64-3.3\send_email.exe 
copying C:\Windows\SYSTEM32\python33.dll -> build\exe.win-amd64-3.3\python33.dll 

Traceback (most recent call last): 
    File "setup.py", line 17, in <module> 
    executables = [Executable("send_email.py", icon="icon.ico", base=base)]) 
    File "c:\Python33\lib\site-packages\cx_Freeze\dist.py", line 365, in setup 
    distutils.core.setup(**attrs) 
    File "c:\Python33\lib\distutils\core.py", line 148, in setup 
    dist.run_commands() 
    File "c:\Python33\lib\distutils\dist.py", line 917, in run_commands 
    self.run_command(cmd) 
    File "c:\Python33\lib\distutils\dist.py", line 936, in run_command 
    cmd_obj.run() 
    File "c:\Python33\lib\distutils\command\build.py", line 126, in run 
    self.run_command(cmd_name) 
    File "c:\Python33\lib\distutils\cmd.py", line 313, in run_command 
    self.distribution.run_command(command) 
    File "c:\Python33\lib\distutils\dist.py", line 936, in run_command 
    cmd_obj.run() 
    File "c:\Python33\lib\site-packages\cx_Freeze\dist.py", line 235, in run 
    freezer.Freeze() 
    File "c:\Python33\lib\site-packages\cx_Freeze\freezer.py", line 577, in Freeze 

    self._FreezeExecutable(executable) 
    File "c:\Python33\lib\site-packages\cx_Freeze\freezer.py", line 169, in _Freez 
eExecutable 
    cx_Freeze.util.AddIcon(exe.targetName, exe.icon) 
SystemError: error return without exception set 
+0

我以前沒見過的那一個。你可以[提出問題](https://bitbucket.org/anthony_tuininga/cx_freeze/issues/new),以便它不會被遺忘嗎? –

回答

1

我有同樣的消息錯誤,我給予的圖標文件的完整路徑固定它。 順便說一下,確保圖標是在.ico格式(起初我將.png文件的擴展名重命名爲.ico,並導致進程崩潰,最後我將.png文件轉換爲.ico格式,並將其工作)。

0

使用此安裝文件。

from cx_Freeze import setup, Executable 

GUI2Exe_Target_1 = Executable(
    script = "Your scripts", 
    initScript = None, 
    base = 'Win32GUI', 
    targetName = "app.exe", 
    compress = True, 
    copyDependentFiles = True, 
    appendScriptToExe = False, 
    appendScriptToLibrary = False, 
    icon = "YOUR ICON FILE.ico" 
    ) 
excludes = ["pywin", "tcl", "pywin.debugger", "pywin.debugger.dbgcon", 
     "pywin.dialogs", "pywin.dialogs.list", "win32com.server", 
     "email"] 
includes = ["PyQt4.QtCore","PyQt4.QtGui","win32gui","win32com","win32api","html.parser","sys","threading","datetime","time","urllib.request","re","queue","os"] 
packages = [] 
path = [] 
setup(
    version = "1.0", 
    description = "myapp", 
    author = "me", 
    author_email = "[email protected]", 
    name = "Your app name !", 
    options = {"build_exe": {"includes": includes, 
          "excludes": excludes, 
          "packages": packages, 
          "path": path 
          } 
       }, 
    executables = [GUI2Exe_Target_1] 
    ) 
0

我有相同的確切錯誤,我現在就修好了!有一個非常簡單的解決方案,你得到這個錯誤,因爲你的圖標文件。

  1. 我想你有一個setup.py文件,其中沿着executables = [cx_Freeze.Executable("filename.py", base=base, icon="youricon")]

你需要確保你的圖標是一個.ico文件線的東西。只需搜索.gif或.png到.ico轉換器,它就會爲您做到!

請確保您的.ico文件位於文件的文件夾內。 確保包括在選項

你可能在沿線的你setup.py別的文件...

options = {"build_exe":{"packages":["THEMODS YOU IMPORTED HERE"],"include_files":["THE FILES NEED TO BE HERE"]} 

這是固定的問題對我來說。 LMK如果這能幫助:)

0

更改選項:

build_exe_options = {"packages": ["os"], "excludes": ["tkinter"],"include_files": ["icon.ico"],} 
相關問題