【发布时间】:2018-11-23 02:43:18
【问题描述】:
我用这段代码和 pyinstaller 创建了一个可执行文件:
import soundfile
print("Hello!")
input("Ok")
但它运行不正确。我收到以下错误:
Traceback (most recent call last):
File "lib\site-packages\soundfile.py", line 142, in <module>
OSError: sndfile library not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "prueba.py", line 1, in <module>
import soundfile
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "C:\Users\DianaCarolina\Google Drive\Humboldt\DTF_GUI\venv1\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "lib\site-packages\soundfile.py", line 163, in <module>
OSError: cannot load library 'C:\Users\DianaCarolina\Google Drive\Humboldt\DTF_GUI\dist\prueba\_soundfile_data\libsndfile32bit.dll': error 0x7e
[9780] Failed to execute script prueba
由于我使用了标准的 pyinstaller 命令pyinstaller prueba.py,我能够通过复制 dist 文件夹中的原始 _soundfile_data 文件夹来使可执行文件工作。但是,我想使用 --onefile 选项使我的程序更易于分发。如何让 pyinstaller 按预期工作?
【问题讨论】:
标签: python-3.x pyinstaller libsndfile