pythonpyinstallerspire.xls

Spire.XLS with pyinstaller


I am using spire.xls in my python script. When script executed from VS code evetything works as expected. I have created executable using pyinstaller. Added specific dlls.

pyinstaller --noconfirm --onefile --console --add-data "I:\_DEV\Scripts\venv\Lib\site-packages\spire\xls\lib\Spire.Xls.Base.dll;." --add-data "I:\_DEV\Scripts\venv\Lib\site-packages\spire\xls\bin\Spire.XLS.dll;." --add-data "I:\_DEV\Scripts\jvenv\Lib\site-packages\spire\xls\lib\libSkiaSharp.dll;."  "I:\_DEV\Scripts\XXXX_Report.py"

When executable is running i get an error:

An exception of type AttributeError occurred. Arguments: ("'NoneType' object has no attribute 'Workbook_CreateWorkbook'",)


Solution

  • add-data is for including non-binary files. To include .dll files, use add-binary.

    Here is an example command (make sure to update the DLL paths and names to match your environment):

    pyinstaller --add-binary ./libSkiaSharp.dll:./spire/pdf/lib --add-binary ./Spire.Pdf.Base.dll:./spire/pdf/lib Xinvoice.py