pyInstaller无法捆绑包含SWIG模块的软件包

时间:2018-12-26 22:44:13

标签: python swig pyinstaller

我遇到了使pyInstaller捆绑包含SWIG模块的模块的问题。我已遵循pyInstaller文档中列出的每个准则,其中详细介绍了SWIG支持。 运行exe时出现以下错误:

# sphinxbase._ad_win32 not found in PYZ
Traceback (most recent call last):
  File "StartListening.py", line 10, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "c:\users\allen\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\sphinxbase\__init__.py", line 35, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "c:\users\allen\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\sphinxbase\ad_win32.py", line 32, in <module>
  File "site-packages\sphinxbase\ad_win32.py", line 31, in swig_import_helper
  File "importlib\__init__.py", line 126, in import_module
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'sphinxbase._ad_win32'

但是,sphinxbase._ad_win32确实作为pyd文件存在。我正在运行Windows 10;为何pyInstaller捆绑此模块时遇到问题? 我最终尝试导入的第三方程序包是SpeechRecognition,该程序依赖于Pocketsphinx,而后者取决于有问题的模块sphinxbase。

这是

返回的对象引用
importlib.import_module('sphinxbase._ad_win32') 

在SWIG生成的python包装器中

如果这对某人有帮助:

<module 'sphinxbase._ad_win32' from 'C:\\Users\\bob\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\sphinxbase\\_ad_win32.pyd'>

Python版本:3.6.5

编辑:经过更多研究,我尝试将.pyd添加到.spec文件的'binaries'列表中,并将'sphinxbase._ad_win32'添加到'hidden-imports'列表及其之间的组合中,但这也不起作用。二进制文件在那里,在正确的位置,我无法弄清楚为什么捆绑的应用程序找不到它。

0 个答案:

没有答案