我使用 py2exe 使用 64 位 python 解释器和 32 位 python 解释器创建了 python 可执行文件。
在我的程序中,我使用模块 pywin32 com
,因此我在创建可执行文件之前下载并安装了该程序的 64 位和 32 位版本。
64 位 exe 运行正常,但 32 位 exe 存在以下问题:
Traceback (most recent call last):
File "program.py", line 11, in <module>
File "win32com\__init__.pyc", line 5, in <module>
File "win32api.pyc", line 12, in <module>
File "win32api.pyc", line 10, in __load
ImportError: DLL load failed: The specified procedure could not be found.
我通过直接运行源代码尝试了这两个版本,即python program.py
和C:\python_32\python.exe program.py
并且都工作正常。
注意我在 64 位 Windows 7 计算机上测试了 64 位 exe,在 32 位 Windows XP 计算机上测试了 32 位 exe。
最佳答案
比以往任何时候都古老,但我今天偶然发现了这个问题,如果其他人这样做,我运行的是:
从命令行python/c/Python26/Scripts/pywin32_postinstall.py -install
(更改值以适应)。有效:
$ python /c/Python26/Scripts/pywin32_postinstall.py -install
Copied pythoncom26.dll to C:\WINDOWS\system32\pythoncom26.dll
Copied pythoncomloader26.dll to C:\WINDOWS\system32\pythoncomloader26.dll
Copied pywintypes26.dll to C:\WINDOWS\system32\pywintypes26.dll
Registered: Python.Interpreter
Registered: Python.Dictionary
Registered: Python
-> Software\Python\PythonCore\2.6\Help[None]=None
-> Software\Python\PythonCore\2.6\Help\PythonwinReference[None]='c:\\Python26\\Lib\\site-packages\\PyWin32.chm'
Pythonwin has been registered in context menu
Creating directory c:\Python26\Lib\site-packages\win32com\gen_py
Shortcut for Pythonwin created
Shortcut to documentation created
The pywin32 extensions were successfully installed.`
(在 WinXP SP3 上)
关于python - 由 pywin32 生成的 python 可执行文件中的 dll 加载错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6379195/