python-3.x RuntimeError:找不到MXNet库

hmae6n7t  于 2023-07-01  发布在  Python
关注(0)|答案(2)|浏览(201)

我想为我的代码创建可执行文件,其中我使用mxnet和pyinstaller。
我得到了这个错误

File "mxnet/libinfo.py", line 74, in find_lib_path
RuntimeError: Cannot find the MXNet library.
List of candidates:
/home/rit/test/exe/dist/test/libmxnet.so
/home/rit/test/exe/dist/test/libmxnet.so
/home/rit/test/exe/dist/test/mxnet/libmxnet.so
/home/rit/test/exe/dist/test/mxnet/../../lib/libmxnet.so
/home/rit/test/exe/dist/test/mxnet/../../build/libmxnet.so

添加了libmxnet.so虽然规范文件,但给我PyInstallerImportError
通过pip卸载mxnet并将python3.5/dist-packages/mxnet复制到我的项目中,面临同样的问题。

File "PyInstaller/loader/pyiboot01_bootstrap.py", line 151, in __init__
__main__.PyInstallerImportError: Failed to load dynlib/dll '/home/rit/test/exe/dist/test/libmxnet.so'. Most probably this dynlib/dll was not found when the application was frozen.

什么是dynlib/dll?如何解决这个错误?
谢谢

pengsaosao

pengsaosao1#

MXNet在冻结时需要外部二进制文件。您可以使用add-data标志将libmxnet文件添加到可执行文件中:

pyinstaller -F --add-data="<python_path>/lib/python3.7/site-packages/mxnet/*.so*:./mxnet" script.py
fwzugrvs

fwzugrvs2#

如果你用的是linux,可以像我一样运行。

find / -name "libmxnet.so"
export MXNET_LIBRARY_PATH={result of you find}

我的find结果是这样的:

/opt/apps/mxnet/build/libmxnet.so
/usr/local/mxnet/libmxnet.so

所以我会做:

export MXNET_LIBRARY_PATH=/usr/local/mxnet/libmxnet.so

相关问题