pyexcel hook missing in pyinstaller (unable to load pyexcel)

972 Views Asked by At

I am using below code to convert .xls file to .xlsx. It works fine when I run it normally or in debug mode, but If I convert this to the executable file(.exe ) the below code is not working. I guess pyinstaller doesn't have pyexcel hook to load the import. Is there any way I can add this import pyexcel to pyinstaller ??

import pyexcel

pyexcel.save_as(file_name=path_Xls, dest_file_name=path_Xls+'x') I have Installed pyexcel-xls on my system, still getting this error

Error in console

1

There are 1 best solutions below

0
On

Short Answer

Please append these lines to your command line:

--hidden-import pyexcel_xls --hidden-import pyexcel_xls.xls
--hidden-import pyexcel_xlsx --hidden-import pyexcel_xlsx.xlsx

Please also note, this solution works only with pyexcel-io v0.3.x and pyexcel v0.4.x

Long Answer

pyexcel-io plugins are lazy-loaded, in other words are imported when they are used. That is why pyinstaller cannot package the hidden imports into your executable by simply reading the source codes without knowing its runtime behaviour.

Here is the documentation on pyexcel-io v0.3.4 with pyinstaller

More information

With the latest pyexcel v0.5.0 and pyexcel-io 0.4.0, there are more options to be appended, I am afraid, because all built-in plugins become lazy-loaded too. Here are the corresponding documentations: pyinstaller on pyexcel and pyexcel-io