I'm currently using Spire.Xls==14.2.2 (the only version available at this point of writing), using macOS Intel chip.

When running a simple code snippet below:

from spire.xls import Workbook

workbook = Workbook()

I'm getting the below error:

Traceback (most recent call last):
  File "/.../test.py", line 10, in <module>
    workbook = Workbook()
  File "/.../lib/python3.9/site-packages/plum/function.py", line 642, in __call__
    return self.f(self.instance, *args, **kw_args)
  File "/.../plum/function.py", line 592, in __call__
    return _convert(method(*args, **kw_args), return_type)
  File "/.../spire/xls/Workbook.py", line 18, in __init__
    intPtr = CallCFunction(GetDllLibXls().Workbook_CreateWorkbook)
  File "/.../spire/xls/common/__init__.py", line 109, in CallCFunction
    raise SpireException(info)
spire.xls.common.SpireException: TypeInitialization_Type_NoTypeAvailable:   at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x148
   at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnNonGCStaticBase(StaticClassConstructionContext*, IntPtr) + 0x9
   at Spire.Xls.Core.Spreadsheet.XlsWorksheet.InitializeCollections() + 0x2c2
   at Spire.Xls.Core.Spreadsheet.XlsWorksheet..ctor(Object) + 0x74
   at Spire.Xls.Core.Spreadsheet.Collections.XlsWorksheetsCollection.Add(String) + 0x7a
   at Spire.Xls.Core.Spreadsheet.XlsWorkbook.spra(Int32) + 0x369
   at Spire.Xls.Workbook..ctor() + 0x4f
   at Spire.Xls.AOT.NLWorkbook.CreateWorkbook(IntPtr) + 0x4c

It seems to be trying to load some DLLs (under the GetDllLibXls) while I have installed a mac version of the library. Any idea how to get past this?

1

There are 1 best solutions below

0
Dheeraj Malik On

To solve this problem, you need to copy the libskiasharp.dylib file from the installation directory (for example, /usr/local/lib/python3.9/site-packages/spire/xls/lib) of the lib to the root directory of your project. enter image description here