我遇到cx-freeze的问题,它无法加载我创建的dll
我的setup.py:
import sys
import clr
executablePath = 'E:\\PythonWS\\myWorkSpace\\'
sys.path.append(executablePath)
clr.AddReference("mydll")
print clr.FindAssembly('mydll')
import mydll
from cx_Freeze import setup, Executable
zhuli = mydll.fun()
zhuli.doTheThing()
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": [
'os', 'matplotlib.figure', 'matplotlib.backends.backend_qt4agg',
'PyQt4.QtGui', 'PyQt4.Qt', 'sys'
],
"include_files": [
'mydll',
],
"excludes": [
'tkinter',
],
'init_script':'Console'}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup( name = "guifoo",
version = "0.1",
description = "My GUI application!",
options = {"build_exe": build_exe_options},
executables = [Executable("test.py", base=base)])
结果
cx_Freeze.freezer.ConfigError: cannot find file/directory named mydll
虽然在开头打印:
E:\PythonWS\myWorkSpace\mydll.dll
而zhuli.doTheThing()
做的事情......
所以对我而言,这意味着它知道哪里 dll,它可以访问但是由于某种原因不想加载它。任何人都有这个想法??
感谢您的时间。
编辑:
这就是我在tmp.appcompat.txt
:
<?xml version="1.0" encoding="UTF-16"?>
<DATABASE>
<EXE NAME="test.exe" FILTER="CMI_FILTER_PRIVACY">
...
<MATCHING_FILE NAME="mydll.dll" SIZE="77824" CHECKSUM="0x5950C084" BIN_FILE_VERSION="1.0.0.0" BIN_PRODUCT_VERSION="1.0.0.0" PRODUCT_VERSION="1.0.0.0" FILE_DESCRIPTION="mydll" PRODUCT_NAME="mydll" FILE_VERSION="1.0.0.0" ORIGINAL_FILENAME="mydll.dll" INTERNAL_NAME="mydll.dll" LEGAL_COPYRIGHT="Copyright © 2012" VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="1.0.0.0" UPTO_BIN_PRODUCT_VERSION="1.0.0.0" LINK_DATE="07/01/2015 14:55:50" UPTO_LINK_DATE="07/01/2015 14:55:50" VER_LANGUAGE="Independiente del idioma [0x0]" EXE_WRAPPER="0x0" />
...
</EXE>
<EXE NAME="kernel32.dll" FILTER="CMI_FILTER_THISFILEONLY">
<MATCHING_FILE NAME="kernel32.dll" SIZE="1114112" CHECKSUM="0x1325986C" BIN_FILE_VERSION="6.1.7601.19018" BIN_PRODUCT_VERSION="6.1.7601.19018" PRODUCT_VERSION="6.1.7601.18015" FILE_DESCRIPTION="Archivo DLL de cliente API BASE de Windows NT" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Sistema operativo Microsoft® Windows®" FILE_VERSION="6.1.7601.18015 (win7sp1_gdr.121129-1432)" ORIGINAL_FILENAME="kernel32" INTERNAL_NAME="kernel32" LEGAL_COPYRIGHT="© Microsoft Corporation. Reservados todos los derechos." VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x11C776" LINKER_VERSION="0x60001" UPTO_BIN_FILE_VERSION="6.1.7601.19018" UPTO_BIN_PRODUCT_VERSION="6.1.7601.19018" LINK_DATE="09/29/2015 03:00:35" UPTO_LINK_DATE="09/29/2015 03:00:35" EXPORT_NAME="KERNEL32.dll" VER_LANGUAGE="Español (España, internacional) [0xc0a]" EXE_WRAPPER="0x0" />
</EXE>
</DATABASE>`
编辑2:
在创建日志之后,我意识到这是崩溃应用程序的import clr
任何?
答案 0 :(得分:0)
首先,您应该在设置中提供 .dll
文件的完整路径:
"include_files":
[
'mydll',
]
然后,在构建可执行文件时,您应确保'看到'您的dll
。将其复制到可执行文件所在的目录中,然后启动.exe
文件。
如果某个程序使用某个库(在您的情况下为.dll
文件),它应该'知道'在哪里找到它。搜索此库有特殊路径,包括可执行文件所在的路径。如果缺少此库,则应用程序可能会崩溃。