Python 2.6에서 Win32file.pyd로드하는 데 문제가 있습니다
-
10-07-2019 - |
문제
py2exe가 win32file을 사용하는 간단한 스크립트조차도 Py2Exe를 올바르게 포장 할 수 없습니다.
Traceback (most recent call last):
File "dependency_checker.py", line 1, in <module>
File "win32file.pyc", line 12, in <module>
File "win32file.pyc", line 10, in __load
ImportError: DLL load failed: The specified procedure could not be found.
스크립트는 다음과 같이 보입니다.
import win32file
print "Hello world!"
그리고 여기에 setup.py가 있습니다.
from distutils.core import setup
import py2exe
setup(console=['dependency_checker.py'])
전에 비슷한 문제가 있었습니까?
버전 :
Python 2.6.2, Py2Exe 0.6.9, Pywin32-214, Windows 7 및 Windows XP Pro는 대상 기기로
업데이트:
- 창 7에서 번들 프로그램을 만들 수 있지만 XP 머신에서 실행할 수는 없습니다.
오류가 발생하는 win32file.pyc의 일부는 다음과 같이 보입니다.
>>> imp.load_dynamic('win32file', r'C:\test\setup-test\src\dist\win32file.pyd')
내 Dev Box (Windows 7)의 위의 줄은 테스트 박스 (Windows XP)에서 오류를 반환하는 동안 올바르게 실행됩니다.
** 업데이트 2 : **
imp.load_dynamic을 사용하여 Win32File 양식 Python 설치를로드하면 오류없이 Dist 폴더의 Win32File.pyd를 다시로드 할 수 있습니다.
해결책
Soution은 py2exe에 의해 Dist 디렉토리에 복사 된 MSWSOCK.DLL을 제거하는 것이 었습니다.
Procmon과 ListDll을 사용하여 Import가 성공할 때 Win32file.pyd가로드 한 내용과 가져 오기가 실패 할 때 DLL이로드되는 내용을 확인했습니다. 그런 다음 DLL 목록이 올바르게로드되었는지 확인했습니다. Dist Folder의 Python DLL 및 Windows 폴더의 Windows DLL.
다음은 잘 작동하는 Setup.py입니다
from distutils.core import setup
import py2exe
setup(console=['dependency_checker.py'],
options={'py2exe': {"dll_excludes": ["mswsock.dll", "MSWSOCK.dll"]}}
)
제휴하지 않습니다 StackOverflow