gpt4 book ai didi

python - 如何解决这个 dll 加载 python 错误?

转载 作者:行者123 更新时间:2023-11-30 23:58:44 27 4
gpt4 key购买 nike

我在 python 代码中使用了一个 c++ dll。当我在计算机上运行 python 应用程序时,它工作正常,但是当我将所有内容复制到另一台计算机时,会发生这种情况:

Traceback (most recent call last):
File "C:\users\Public\SoundLog\Code\Código Python\SoundLog\SoundLog.py", line 9, in <module>
from Auxiliar import *
File "C:\users\Public\SoundLog\Code\Código Python\SoundLog\Auxiliar\DataCollection.py", line 4, in <module>
import SoundLogDLL
File "C:\users\Public\SoundLog\Code\Código Python\SoundLog\Auxiliar\SoundLogDLL.py", line 4, in <module>
dll = cdll.LoadLibrary(os.environ['PUBLIC'] + "\\SoundLog\\DLLs\\ForPython\\SoundLogC++WrapperDLL.dll")
File "C:\Python26\lib\ctypes\__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "C:\Python26\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 14001] The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail

如何解决这个问题,以便我的 python 应用程序在每台计算机上都能运行?

注意:我只需要它们像我一样在 Windows 7 上工作。我在另一台win7电脑上进行了测试(均为32位)。

最佳答案

您使用的 DLL 依赖于目标计算机上未安装的 Microsoft Visual C++ 运行时。您有几个选择:

  • 将 Visual C++ 运行时库安装或复制到目标计算机。通过将合并模块添加到安装程序(如果有)或运行可再发行安装程序 (vcredist.exe) 来完成安装。记录了各种方法here适用于VS2005(其他版本类似)。

  • 如果您构建了 DLL,则可以更改项目设置以静态链接运行时库。请参阅this answer看看这是如何完成的。

关于python - 如何解决这个 dll 加载 python 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2852652/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com