【发布时间】:2022-08-03 07:20:33
【问题描述】:
我目前正试图让我的项目作为可执行文件工作,以便我可以更轻松地共享它,但是所涉及的代码导入了一些 c 代码以使用 ctypes 库提高速度。我正在使用 pyinstaller 来生成我的 .exe,它工作正常,除了 CDLL ctype 函数,如下面的代码所示:
from ctypes import CDLL
import time
foo_lib_path = \'theories/foo.so\'
foo = CDLL(foo_lib_path)
print(\'Mission accomplished\')
time.sleep(10)
当我在正常环境中运行此代码时,它可以正常工作,但是当我使用 pyinstaller --onefile \'bar.py\' 或 pyinstaller --hidden-import \'theories/foo.so\' --onefile \'bar.py\' 编译为 exe 时,它会立即中断。我如何解释在我的代码中导入 c 库?
标签: python c import pyinstaller exe