1

使用嵌入到我的 C++ 应用程序(32 位)并静态链接的 Python 2.7 访问 numpy 时,我遇到了问题。在我的应用程序可执行文件下,我将 python27.dll 与 Python27 目录以及所有需要的 DLL 一起放置。我还在单独的文件夹 (C:\Python27) 中安装了 Python 2.7 和 numpy(均为 32 位)。当我运行我的应用程序并尝试导入 numpy 时,我收到以下错误:

Traceback (most recent call last):
File "pytest", line 1, in <module>
    File "C:\Python27\lib\site-packages\numpy\__init__.py", line 137, in <module>
    import add_newdocs
    File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in <module>
    from numpy.lib import add_newdoc
    File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
    from type_check import *
    File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
    import numpy.core.numeric as _nx
    File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 5, in <module>
    import multiarray
ImportError: DLL load failed: The specified module could not be found.

当我从我的应用程序文件夹中删除 python27.dll 时,我可以导入 numpy。当客户想要导入任何 Python 第三方库时,我不能要求客户手动删除 python27.dll ......有人对我如何解决这个问题有想法吗?这个多阵列模块是怎么回事?

4

1 回答 1

2

好的,问题解决了。嵌入式应用程序文件夹下的 python27.dll 文件必须与 Python 2.7 版本相同。验证日期以确保它们相同。如果它们不相同,您可能会遇到各种问题。

My Application Folder
    myApp.exe
    python27.dll  <-- must be the same as Python installed on your machine
    Python27 Folder
        DLL
        Libs
于 2013-01-11T17:44:50.497 回答