我是Python和编码新手。我试图搜索帖子,但似乎我找不到其他人面临同样的问题。
我在Windows 10上使用Python 2.7和opencv3.0。
我尝试使用py2exe将.py文件转换为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-win-core-registry-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 :(得分:3)
我想我已经弄清楚究竟是什么问题了。这是因为cv2.pyd依赖于某些系统级别的dll(尝试" dumpbin / dependents cv2.pyd",如果安装了Visual Studio),py2exe不会忽略它们,例如:
"dll_excludes": ["MSVFW32.dll",
"AVIFIL32.dll",
"AVICAP32.dll",
"ADVAPI32.dll",
"CRYPT32.dll",
"WLDAP32.dll"]
这些dll回复了" api-ms-win-core - *****"。如果要将软件分发到其他计算机,则不应复制这些DLL。
所以最后,一个更明智的解决方案可能是排除上面的dll,而不是" api-ms-win-core - *****",这样问题应该是也可以解决,
page
答案 1 :(得分:3)
我没有使用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',
]
答案 2 :(得分:2)
几乎没有一个富有洞察力的答案,但我遇到了同样的问题,并且可以说需要排除的api-ms-core * 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"]
之后一切正常。