2015-12-29 119 views
6

我是一個Python和編碼newbie.I曾試圖搜索帖子,但似乎我找不到其他人面臨同樣的問題。當導入opencv時,由於缺少DLL導致py2exe無法創建EXE

我使用Python 2.7和opencv3.0在Windows 10

我想我的.py文件轉換爲使用py2exe一個EXE文件。 但是,命令窗口告訴我。

error: [Errno 2] No such file or directory: 'api-ms-win-core-registry-l1-1-0.dll' 

這是我的setup.py

from distutils.core import setup 
import py2exe 
import matplotlib 
import FileDialog 
setup(windows=['HW6.py'], 
     options={ 
       'py2exe': { 
       "includes" : ["matplotlib.backends.backend_tkagg","cv2"], 

       'excludes': ['_gtkagg', '_tkagg', '_agg2', '_cairo','_cocoaagg', 
           "matplotlib.numerix.fft","sip", "PyQt4._qt", 
           "matplotlib.backends.backend_qt4agg", 
           "matplotlib.numerix.linear_algebra", 
           "matplotlib.numerix.random_array", 
          '_fltkagg', '_gtk','_gtkcairo' ], 

       'dll_excludes': ['libgdk-win32-2.0-0.dll', 
           'libgobject-2.0-0.dll' , 
           'MSVCP90.dll'] 
       } 

       }, 

     data_files=matplotlib.get_py2exe_datafiles(),) 

後,我排除了 'API-MS-雙贏核心註冊表l1-1-0.dll',另一個錯誤彈出,說

error: [Errno 2] No such file or directory: 'api-ms-win-core-errorhandling-l1-1-1.dll' 

在我排除了大量的DLL之後,仍然有一些DLL丟失了。 這裏是什麼我已經排除

'api-ms-win-core-string-l1-1-0.dll', 
'api-ms-win-core-registry-l1-1-0.dll', 
'api-ms-win-core-errorhandling-l1-1-1.dll', 
'api-ms-win-core-string-l2-1-0.dll', 
'api-ms-win-core-profile-l1-1-0.dll', 
'api-ms-win-core-processthreads-l1-1-2.dll', 
'api-ms-win-core-libraryloader-l1-2-1.dll', 
'api-ms-win-core-file-l1-2-1.dll', 
'api-ms-win-security-base-l1-2-0.dll', 
'api-ms-win-eventing-provider-l1-1-0.dll', 
'api-ms-win-core-heap-l2-1-0.dll', 
'api-ms-win-core-libraryloader-l1-2-0.dll', 
'api-ms-win-core-localization-l1-2-1.dll', 
'api-ms-win-core-sysinfo-l1-2-1.dll', 
'api-ms-win-core-synch-l1-2-0.dll', 
'api-ms-win-core-heap-l1-2-0.dll' 

這裏是進口的東西 'HW6.py'

import matplotlib.pyplot as plt 
from Tkinter import * 
from PIL import ImageTk,Image 
import numpy as np 
import copy 
import FileDialog 
import warnings 
import cv2 

沒有

import cv2 

,一切工作正常。 我不知道如何處理這些DLL。 謝謝!

+0

拼寫錯誤? ''在我排除了很多DLL之後,仍然有一些DLL丟失了''注** **排除** – Torxed

+0

我不認爲它是拼寫問題。我真的想「排除」DLL而不是包含它們,這在我遇到這種問題之前適用於我。但是這次有太多的DLL出錯了,我不知道如何解決它。 – tsao

回答

2

幾乎沒有一個有見地的答案,但我有同樣的問題,可以說,API-MS-核心*的DLL需要排除的完整列表,對我來說是:

"dll_excludes": ["MSVCP90.dll","libzmq.pyd","geos_c.dll","api-ms-win-core-string-l1-1-0.dll","api-ms-win-core-registry-l1-1-0.dll","api-ms-win-core-errorhandling-l1-1-1.dll","api-ms-win-core-string-l2-1-0.dll","api-ms-win-core-profile-l1-1-0.dll","api-ms-win*.dll","api-ms-win-core-processthreads-l1-1-2.dll","api-ms-win-core-libraryloader-l1-2-1.dll","api-ms-win-core-file-l1-2-1.dll","api-ms-win-security-base-l1-2-0.dll","api-ms-win-eventing-provider-l1-1-0.dll","api-ms-win-core-heap-l2-1-0.dll","api-ms-win-core-libraryloader-l1-2-0.dll","api-ms-win-core-localization-l1-2-1.dll","api-ms-win-core-sysinfo-l1-2-1.dll","api-ms-win-core-synch-l1-2-0.dll","api-ms-win-core-heap-l1-2-0.dll","api-ms-win-core-handle-l1-1-0.dll","api-ms-win-core-io-l1-1-1.dll","api-ms-win-core-com-l1-1-1.dll","api-ms-win-core-memory-l1-1-2.dll","api-ms-win-core-version-l1-1-1.dll","api-ms-win-core-version-l1-1-0.dll"] 

一切工作正常之後。

+0

哇,多長的列表!我會在幾天後嘗試一下,並報告它是否也適用於我。非常感謝! – tsao

3

我想我已經弄清楚究竟是什麼問題了。這是因爲cv2.pyd依賴於某些系統級別的dll(如果安裝了Visual Studio,請嘗試「dumpbin/dependents cv2.pyd」),並且py2exe不會忽略它們。

MSVFW32.dll 
AVIFIL32.dll 
AVICAP32.dll 
ADVAPI32.dll 
CRYPT32.dll 
WLDAP32.dll 

而這些DLL回答「api-ms-win-core-*****」。如果你想分發你的軟件到其他機器,這些DLL不應該被複制。

所以最後一個更合理的解決方案可能是排除上面的dll而不是「api-ms-win-core-*****」,這樣,問題也應該解決,

"dll_excludes": ["MSVFW32.dll", 
       "AVIFIL32.dll", 
       "AVICAP32.dll", 
       "ADVAPI32.dll", 
       "CRYPT32.dll", 
       "WLDAP32.dll"] 
0

我沒有使用opencv,但卡住了同一問題。改變py2exe告訴我哪些圖像導入哪些DLL後,我發現擴展列表以包括下面的工作爲我的導入庫(即使有些硬編碼已被排除在py2exe本身已經 - 代碼註釋表明它並不全面) :

"dll_excludes": [ 
'MSVCP90.dll', 
'IPHLPAPI.DLL', 
'NSI.dll', 
'WINNSI.DLL', 
'WTSAPI32.dll', 
'SHFOLDER.dll', 
'PSAPI.dll', 
'MSVCR120.dll', 
'MSVCP120.dll', 
'CRYPT32.dll', 
'GDI32.dll', 
'ADVAPI32.dll', 
'CFGMGR32.dll', 
'USER32.dll', 
'POWRPROF.dll', 
'MSIMG32.dll', 
'WINSTA.dll', 
'MSVCR90.dll', 
'KERNEL32.dll', 
'MPR.dll', 
'Secur32.dll', 
] 
相關問題