我正在创建导入Microsoft的LightGBM的python代码的单文件可执行文件。我使用以下命令创建了exe:
pyinstaller -F --hidden-import numpy.core._dtype_ctypes pro.py
创建并运行exe后,会发生以下错误:
Exception: Cannot find lightgbm library file in following paths:
C:\Users\...\AppData\Local\Temp\_MEI61682\lightgbm\lib_lightgbm.dll
C:\Users\...\AppData\Local\Temp\lib_lightgbm.dll
C:\Users\...\AppData\Local\Temp\_MEI61682\lightgbm\compile\lib_lightgbm.dll
C:\Users\...\AppData\Local\Temp\_MEI61682\compile\lib_lightgbm.dll
C:\Users\...\AppData\Local\Temp\lib\lib_lightgbm.dll
C:\Users\...\AppData\Local\Temp\_MEI61682\compile\Release\lib_lightgbm.dll
C:\Users\...\AppData\Local\Temp\_MEI61682\compile\windows\x64\DLL\lib_lightgbm.dll
C:\Users\...\AppData\Local\Temp\Release\lib_lightgbm.dll
C:\Users\...\AppData\Local\Temp\windows\x64\DLL\lib_lightgbm.dll
[6352] Failed to execute script pro
我尝试使用选项添加lib_lightgbm.dll
:
--add-data lib_lightgbm.dll;\compile
这解决了安装lightgbm的计算机上的错误,但是在其他计算机上,它给出了以下错误:
Traceback (most recent call last):
File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 149, in __init__
File "ctypes\__init__.py", line 348, in __init__
OSError: [WinError 126] The specified module could not be found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "pro.py", line 9, 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\...\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
File "site-packages\lightgbm\__init__.py", line 8, 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\...\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
File "site-packages\lightgbm\basic.py", line 34, in <module>
File "site-packages\lightgbm\basic.py", line 29, in _load_lib
File "ctypes\__init__.py", line 426, in LoadLibrary
File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 151, in __init__
__main__.PyInstallerImportError: Failed to load dynlib/dll 'C:\\Users\\...\\AppData\\Local\\Temp\\_MEI7562\\lightgbm\\../compile\\lib_lightgbm.dll'. Most probably this dynlib/dll was not found when the application was frozen.
[4060] Failed to execute script pro
有人可以帮助我解决此问题吗?