2014-03-25 111 views
5

我想將我的Python項目轉換爲獨立的可執行文件,以便在沒有安裝Python的其他服務器上運行它。找不到模塊'cx_Freeze__init__'

使用的命令:

python setup.py build > build.log 

當我嘗試運行產生的EXE,它總是吐出以下錯誤信息:

zipimport.ZipImportError: can't find module 'cx_Freeze__init__' 
Fatal Python error: unable to locate initialization module 

Current thread 0x00000b8c (most recent call first): 

我試着來定義我的所有庫m在整個我的項目中使用setup.py模塊,儘管這沒有什麼區別。

我還添加了DLL文件以包含(described in the post cx-freeze doesn't find all dependencies)。

該項目包括下列庫(的pip list輸出):的setup.py

cx-Freeze (4.3.2) 
docopt (0.6.1) 
pip (1.5.4) 
psutil (2.0.0) 
pywin32 (218) 
requests (2.2.1) 
setuptools (2.2) 
virtualenv (1.11.4) 
WMI (1.4.9) 

內容:

include_files=[ 
      (r'C:\Python34\Lib\site-packages\pywin32_system32\pywintypes34.dll', 'pywintypes34.dll'), 
      (r'C:\Python34\Lib\site-packages\pywin32_system32\pythoncom34.dll', 'pythoncom34.dll'),] 

build_exe_options = dict(
    packages=['os', 'concurrent.futures', 'datetime', 'docopt', 'email.mime.text', 'configparser', 'enum', 
       'json', 'logging', 'psutil', 'requests', 'smtplib', 'socket', 'subprocess', 'sys', 'threading', 'time', 
       'wmi', 'pythoncom'], 
    excludes=[], 
    include_files=include_files) 

executable = Executable(
    script = 'pyWatch.py', 
    copyDependentFiles = True, 
    base = 'Console') 

setup( name= "pyWatch", 
     version= "0.1", 
     options= {"build_exe": build_exe_options}, 
     executables= [executable]) 

cx_freeze的輸出(太大,貼在這裏):http://pastebin.com/2c4hUSeD

所有的幫助將不勝感激!

+0

的凍結日誌說它正在製作一個'cx_Freeze__init__'模塊。你可以看看library.zip,看看有沒有'cx_Freeze__init __。pyc'文件嗎? –

+0

@ThomasK:'cx_Freeze__init __。pyc'確實存在於library.zip中。整個郵政編碼的內容可在[這裏](http://pastebin.com/yqcXEYvY)。 –

+0

奇怪。我不能認爲目前可能會造成這種情況。我會繼續思考。 –

回答

0

代替cx_freeze這是最後的版本更新2014年
有一個模塊調用pyinstaller這是2016年 pyinstaller

也很容易過去的版本更新只使用pyinstaller myscript.py和巴姆