【问题标题】:How to fix this dll loading python error?如何修复此 dll 加载 python 错误?
【发布时间】:2011-02-20 14:42:13
【问题描述】:

我在我的 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位)。

【问题讨论】:

    标签: python


    【解决方案1】:

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

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

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

    【讨论】:

    • 特别是 ctypes 库。我不确定 Windows 对它的支持程度。
    • @Bryan:Windows 支持 ctypes 库就好了。这里的错误不是由 ctypes 引起的,而是由恰好使用 ctypes 加载的 DLL 引起的。
    • 我已经安装了 Visual C++ 运行时库并将项目的执行从调试更改为发布^^
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-14
    • 2021-09-13
    • 1970-01-01
    • 2021-01-13
    • 2018-07-06
    • 1970-01-01
    相关资源
    最近更新 更多