2017-03-17 96 views
0

我用py2exe創建編譯我的Python 3.4腳本。它可以在我編譯的PC上運行(Windows 10 64位),但是當我嘗試在沒有安裝Python的另一臺PC(Windows 7 64位)上運行它時,在日誌中出現以下錯誤:Py2Exe TkInter:DLL加載失敗

Traceback (most recent call last): 
    File "PCSpeedDiagnostics.pyw", line 12, in <module> 
    File "C:\Python34\lib\tkinter\__init__.py", line 36, in <module> 
    File "C:\Python34\lib\tkinter\_fix.py", line 65, in <module> 
    File "<loader>", line 10, in <module> 
    File "<loader>", line 8, in __load 
ImportError: (DLL load failed: The specified module could not be found.) 'C:\\Users\\[MY NAME]\\Downloads\\dist\\_tkinter.pyd' 

_tkinter.pyd文件實際上包含在它明顯無法找到的目錄中。

下面是我的setup.py文件:

from distutils.core import setup 
import py2exe, tkinter 

setup(windows=['PCSpeedDiagnostics.pyw'], 
    name="PC Speed Diagnostics Tool", 
    data_files = [('', ['banner.png', 'blank.png', 'dialog_apply.png', 
         'gnome_application_x_executable.png', 'gnome_dialog_error.png', 
         'gnome_document_send.png', 'gnome_document_send_error.png', 
         'gnome_network_offline.png', 'gnome_network_transmit_receive.png', 
         'gnome_network_wireless.png', 'gnome_system_run.png', 
         'iperf3.exe'])], 
    options = { 
     'py2exe': { 
      'bundle_files': 3, 
      'optimize': 2, 
      'includes': ['tkinter'], 
     } 
    }, 
) 

有誰知道我做錯了嗎?

回答

0

感謝https://stackoverflow.com/a/14566647/963265,我現在有答案。

這是我的新setup.py文件:

from distutils.core import setup 
import py2exe, tkinter 

setup(windows=['PCSpeedDiagnostics.pyw'], 
    name="PC Speed Diagnostics Tool", 
    data_files = [('', ['banner.png', 'blank.png', 'dialog_apply.png', 
         'gnome_application_x_executable.png', 'gnome_dialog_error.png', 
         'gnome_document_send.png', 'gnome_document_send_error.png', 
         'gnome_network_offline.png', 'gnome_network_transmit_receive.png', 
         'gnome_network_wireless.png', 'gnome_system_run.png', 
         'tcl86.dll', 'tk86.dll', 'iperf3.exe'])], 
    options = { 
     'py2exe': { 
      'bundle_files': 3, 
      'optimize': 1, 
      'includes': ['tkinter'], 
      'dll_excludes': ['tcl86.dll', 'tk86.dll'], 
     } 
    }, 
) 

和我抄tcl86.dll和tk86.dll到同一目錄下的EXE。