python-3.xpyinstallermxnet

RuntimeError: Cannot find the MXNet library


I want to create executable for my code where i'm using mxnet with pyinstaller.

I got this error

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

Added libmxnet.so though spec file but gave me PyInstallerImportError

Uninstalled mxnet though pip and copied python3.5/dist-packages/mxnet to my project same problem facing.

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.

Now what is dynlib/dll? How to resolve this error?

Thanks


Solution

  • MXNet needs external binaries to be fed when you freeze it. You can use add-data flag to add libmxnet files to your executable:

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