2013-11-24 1 views
4

내 Windows 응용 프로그램에 Python 2.6이 포함되어 있습니다 (예전에 알고 있었지만 우리가 함께 사용해야하는 것입니다). 그것은 기본 파이썬 명령을 실행할 수 있지만 "DLL을 찾을 수 없습니다"나는 오류 (126) 받고 있어요Python이 msvcr90.dll을 열 수 없습니다.

import ctypes 
ctypes.WinDLL("msvcr90.dll") 

를 실행하려고 실패합니다. 응용 프로그램에서 DLL을 발견하면 오류 1114 "DLL 초기화 루틴이 실패했습니다."가 표시됩니다.

업데이트]이 프로그램의 단순한 재현 할 수 있습니다

#include <math.h> 
#include <iostream> 
#undef _DEBUG 
#include <Python.h> 

int main(int argc, char* argv[]) 
{ 
    Py_SetProgramName(argv[0]); 
    Py_Initialize(); 
    PyRun_SimpleString("import pyreadline\n"); 
    Py_Finalize(); 
    std::cout << "Press enter: " << std::endl; 
    char c; 
    std::cin.read(&c, 1); 
    return 0; 
} 

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 

은 내가 ctypes.pyprint self._name를 삽입하기 때문에로드되는 DLL이 msvcr90.dll 것을 알고있다.

응용 프로그램은 pyreadline을로드하는 것을 제외하고 필자가 필요로하는 대부분의 파이썬 스크립트를 실행합니다.

동일한 스크립트는 설치된 Python 실행 파일에서 문제없이 실행됩니다.

왜 이런 이유가있을 수 있습니까?

업데이트 2 단순한 LoadLibrary("msvcr90.dll")도 실패합니다. 'net'의 여러 위치에서 권장하는대로 응용 프로그램 매니페스트에 DLL을 추가했습니다. 이것은 도움이되지 않았습니다.

<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을 열 수 있습니다 내 응용 프로그램을 수행 할 수 없습니다 여기에 실행 파일에 포함로 매니페스트입니다. 나는 당혹 스럽다.

+0

Windows 응용 프로그램은 어떤 버전의 C/C++로 작성 되었습니까? – martineau

+0

@martineau vs2010 (toolchain v10.0, msvcr100.dll) –

+0

나는 그것이 문제의 원인 일 수 있다고 생각합니다. 동시에 두 개의 다른 C/C++ 런타임 라이브러리를 동시에 사용하는 프로그램을 만들려고합니다. Offhand, 내가 파이썬 버전의 옛날 생각할 수있는 유일한 해결책은 VS2010을 사용하여 직접 재구성하려고하는 것입니다. – martineau

답변

5

업데이트 됨!
시스템이 다른 원본에서 msvcr90.dll을로드하려고하기 때문에 문제가 발생합니다. 먼저 응용 프로그램이 시작되면 python 스크립트가 시작됩니다.
문제를 해결하려면 응용 프로그램에 올바른 매니페스트 파일을 배치해야합니다.
나는이 콘텐츠와 함께 프로젝트의 루트에 added.manifest 파일을 만든 :

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
    <dependency> 
    <dependentAssembly> 
     <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" ></assemblyIdentity> 
    </dependentAssembly> 
    </dependency> 
</assembly> 

내가 프로젝트에서이 파일 속성/매니페스트 도구/입력 및 출력을 설정보다/추가 매니페스트 파일
당신은에 오류가 당신의 processorArchitecture = "amd64"에 명시하십시오.
다시 작성한 후에 프로젝트가 올바르게 작동합니다.

+0

Python.exe는 pyreadline을 실행할 수 있으며 내 프로그램은 실행할 수 없습니다. 버그는 pyreadline에서 가장 확실합니다. –

+0

나는 내 대답을 이해하고 바로 잡았다. –

+0

x86과 amd64 버전을 모두 빌드합니다. 방금 확인한 바 있는데, x86 버전은'processorArchitecture = "x86"'을 참조하고 amd64 버전은'processorArchitecture = "amd64"를 참조합니다. 아직 어느 버전도 작동하지 않습니다. –

관련 문제