【问题标题】:Boost.Python examples, Windows 7 x64, "ImportError: DLL load failed: The specified module could not be found."Boost.Python 示例,Windows 7 x64,“ImportError: DLL load failed: The specified module could not be found.”
【发布时间】:2011-12-28 00:58:14
【问题描述】:

我过去 2 天试图从 Boost.Python 启动示例,并尝试加载已编译(使用 bjam)的 pyd 模块时出现“ImportError: DLL load failed: The specified module could not be found”错误。我使用的是 Windows 7 x64、Python 2.7 x64 和 Boost 1.47。我在 StackOverflow 和其他网站上跟进了不同的答案,包括。全新安装(Python 32 和 64 位,Boost 预编译),手动构建 Boost 库,使用依赖遍历器检查 DLL 等等,但都没有成功。我注册分享了解决方案,该解决方案在这里有效,希望可以帮助遇到同样错误的人;)

【问题讨论】:

  • 问题出在KB2264107 Windows update,“修复”DLL 搜索例程(安全修复)。将注册表值 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager] : CWDIllegalInDllSearch 设置为 0,允许正确加载 DLL 文件并正确导入 .pyd 模块。这也可能发生在其他 Windows 版本上。
  • 欢迎来到 SO。请注意,SO 是一个问答网站。它不是一个记录您在编程方面的成就的博客。
  • @joaquin 我知道,但是当有人遇到类似问题时,我该如何分享解决方案?如果是very discouraged manner,并且这个帖子不正确,请版主删除它。
  • 您的回答完全有效,但您不应将您的回答包含在上述 cmets 的位置或问题本身中。尽可能将其作为一个简洁和准确的问题。
  • 好的,谢谢你的提示 :)

标签: python windows-7 import boost-python


【解决方案1】:

两种解决方案,无需使用regedit

  1. 在构建 dll 时添加 BOOST_PYTHON_STATIC_LIBmarco。它会让 boost.python 静态链接到您的 dll 文件,而不是动态加载 在运行时。
  2. 将 boost.python dll 添加到 PATH 或将其复制到 dll 所在的同一目录

【讨论】:

  • 我遇到了同样的问题。它与 DLL 搜索路径有关,但与 KB2264107 Windows 更新(“修复”DLL 搜索例程)无关。 2 是正确的答案。
【解决方案2】:

问题出在 KB2264107 Windows 更新 (http://support.microsoft.com/kb/2264107) 上,“弄乱”了 DLL 搜索例程(安全修复程序)。将注册表值 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager] : CWDIllegalInDllSearch 设置为 0,允许正确加载 DLL 文件并正确导入 .pyd 模块。这也可能发生在其他 Windows 版本上。

【讨论】:

    【解决方案3】:

    我的解决方案是下载 microsoft visual c++ 2015 redistribute https://www.microsoft.com/en-us/download/details.aspx?id=48145

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-18
      • 1970-01-01
      • 1970-01-01
      • 2018-02-23
      • 1970-01-01
      • 1970-01-01
      • 2021-06-14
      相关资源
      最近更新 更多