我想將我的Python 3.4腳本編譯成可執行文件以方便重新分發。我選擇使用cxfreeze,因爲它是支持Python 3。然而,在運行命令時,編譯腳本,我收到以下錯誤屈指可數:CxFreeze Python編譯錯誤
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27
, in <module>
exec(code, m.__dict__)
File "C:\Users\kylec\Desktop\DataMotion\Python\MailChecker.py", line 1, in <mo
dule>
from tkinter import *
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2214, in _find_a
nd_load
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2203, in _find_a
nd_load_unlocked
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_u
nlocked
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_b
ackward_compatible
AttributeError: 'module' object has no attribute '_fix_up_module'
但是,我不明白什麼是除了抱怨_fix_up_module不存在之外,這個錯誤是錯誤的。
UPDATE:
Traceback (most recent call last):
File "cxfreeze", line 5, in <module>
main()
File "C:\Python34\lib\site-packages\cx_Freeze\main.py", line 187, in main
silent = options.silent)
File "C:\Python34\lib\site-packages\cx_Freeze\freezer.py", line 130, in __init
__
for n in self._GetDefaultBinPathExcludes() + binPathExcludes]
File "C:\Python34\lib\site-packages\cx_Freeze\freezer.py", line 270, in _GetDe
faultBinPathExcludes
import cx_Freeze.util
ImportError: DLL load failed: %1 is not a valid Win32 application.
許多其他Q/A的建議使用32位cxfreeze的版本。但我做了我下載這一個:cx_Freeze -4.3.3.win32-py3.4.exe
如果我編譯使用cxfreeze 64位,我沒有得到任何錯誤。但是,結果exe不運行。
這是[已知問題](https://bitbucket.org/anthony_tuininga/cx_freeze/issue/81/python-34-venv-importlib-attributeerror)。您可以從[本網站](http://www.lfd.uci.edu/~gohlke/pythonlibs/#cx_freeze)下載cx_Freeze以避開它。 –
謝謝。我看到它安裝在C:\ Python34 \ Lib \ site-packages \ cx_Freeze中。但我該如何使用它?我是否運行凍結腳本? – Kyle
安裝完成後,使用setup.py腳本或cxfreeze命令以與之前相同的方式凍結應用程序。 –