我正在尝试运行我最近收到的“自制”包裹。它是用 SWIG 包装的本机 C++ 代码。编辑:我已经安装了所有需要的 C++ 依赖项。我知道该软件包可以正常工作,因为它以前是在其他计算机中设置的。
在 __ init __.py 中找到的代码如下:
from sys import version_info
if version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_Pack', [dirname(__file__)])
except ImportError:
import _Pack
return _Pack
if fp is not None:
try:
print ('_Pack', fp, pathname, description)
_mod = imp.load_module('_Pack', fp, pathname, description)
finally:
fp.close()
return _mod
_Hydra = swig_import_helper()
del swig_import_helper
else:
import _Hydra
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.`
当我运行它时,我收到以下错误:
C:\Users\jun\Documents\_test>python __init__.py
Traceback (most recent call last):
File "__init__.py", line 42, in <module>
_Pack = swig_import_helper()
File "__init__.py", line 35, in swig_import_helper
_mod = imp.load_module('_Pack', fp, pathname, description)
File "C:\Users\jun\AppData\Local\Programs\Python\Python35-32\lib\imp.py",
line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\jun\AppData\Local\Programs\Python\Python35-32\lib\imp.py",
line 342, in load_dynamic
return _load(spec)
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 914, in create_module
File "<frozen importlib._bootstrap>", line 222, in
_call_with_frames_removed ImportError: DLL load failed: 找不到指定的模块。
此错误是在 Windows 7 64 位中使用 Python 3.5.3-32 位生成的。我的观察是问题出在 load_module 上,但我真的无法确定模块无法加载的原因。有任何想法吗?