Python ImportError:DLL加载失败:无法优化另一台计算机生成的DLL

时间:2019-04-18 07:27:57

标签: python

总之,计算机A不能引用计算机A生成的DLL。

  1. 使用SWIG软件包获取HKIPCamera_wrap.cxx: (源文件包括HKIPcamera.cpp,HKIPcamera.h和HKIPcamera.i) Swig -I“ D:\ Program Files \ opencv3 \ opencv \ build \ include” -python -c ++ HKIPCamera.i
  2. 创建一个DLL项目,将HKIPcamera.h文件添加到头文件,然后将HKIPcamera_wrap.cxx,HKIPcamera.cpp添加到源文件。
  3. 将生成的.dll文件重命名为_HKIPcamera.pyd并将其放置在HKIPcamera.py的同一目录中,我认为可以在Python中引用该文件。
  4. 生成.dll的计算机A可以正常引用该模块,然后将该.dll移至计算机B。
  5. 通过“ dependecy walker”查询依赖的DLL来加入,但仍然无法工作...
Traceback (most recent call last):
  File "C:\Users\lenovo\Desktop\HIK_YOLO_Python\HKIPcamera.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "D:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 560, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/lenovo/Desktop/HIK_YOLO_Python/test.py", line 1, in <module>
    import HKIPcamera
  File "C:\Users\lenovo\Desktop\HIK_YOLO_Python\HKIPcamera.py", line 17, in <module>
    _HKIPcamera = swig_import_helper()
  File "C:\Users\lenovo\Desktop\HIK_YOLO_Python\HKIPcamera.py", line 16, in swig_import_helper
    return importlib.import_module('_HKIPcamera')
  File "D:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: The specified module could not be found

1 个答案:

答案 0 :(得分:-1)

很好...看来我忘记了一个目录。