我的Windows应用程序嵌入了python2.6(我知道,但这是我们必须使用的)。它可以运行基本的Python命令,但尝试执行失败
import ctypes
ctypes.WinDLL("msvcr90.dll")
我收到错误126“找不到DLL”。如果我把DLL放在应用程序可以找到它的地方,那么我会得到错误1114“DLL初始化例程失败”。在
已更新可使用以下最简单的程序复制:
^{pr2}$在x86和amd64体系结构中,使用V9或v10工具链编译时,这将失败。在
回溯如下:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python26-x86\lib\site-packages\pyreadline\__init__.py", line 9, in <m
odule>
import unicode_helper, logger, clipboard, lineeditor, modes, console
File "C:\Python26-x86\lib\site-packages\pyreadline\console\__init__.py", line
14, in <module>
from console import *
File "C:\Python26-x86\lib\site-packages\pyreadline\console\console.py", line 6
05, in <module>
msvcrt = cdll.LoadLibrary(ctypes.util.find_msvcrt())
File "C:\Python26-x86\Lib\ctypes\__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "C:\Python26-x86\Lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found
-- or alternatively --
WindowsError: [Error 1114] A dynamic link library (DLL) initialization routine f
ailed
我知道正在加载的DLL是msvcr90.DLL,因为我在ctypes.py
中插入了print self._name
。在
应用程序运行我需要的大多数Python脚本,除了那些加载pyreadline
的脚本。在
这些相同的脚本从已安装的Python可执行文件运行,没有问题。在
这可能是什么原因?在
{
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="amd64" publicKeyToken="1fc8b3b9a1e18e3b" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>
此清单和嵌入的清单python.exe匹配,好吗python.exe我的应用程序不能打开DLL,我很困惑。在
我通过重新安装python2.7解决了windows10上另一个Python应用程序的相同错误。在
更新!
发生问题的原因是系统试图从不同的源加载msvcr90.dll。首先当应用程序启动时,然后启动python脚本。
要解决这个问题,您确实应该在应用程序中放置一个正确的清单文件。
我创造了一个已添加。清单包含以下内容的项目根目录中的文件:
然后在项目属性/清单工具/输入和输出/其他清单文件中设置此文件
您在processorArchitecture=“amd64”中的清单中有错误。
重建后工程运转良好。在
相关问题 更多 >
编程相关推荐