We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unable to run Aspose.Cells for Python via Java examples

hello,

I have downloaded the API package from https://downloads.aspose.com/cells/python/new-releases/aspose.cells-for-python-via-java-20.2/ and unable to run the examples in example.py file. I have also installed the API using pip install aspose-cells. The following exception is thrown when running the example:

PS D:\Aspose Works\Aspose.Cells_for_Python_via_Java_20.2> & C:/Users/MY-PC/AppData/Local/Programs/Python/Python38/python.exe "d:/Aspose Works/Aspose.Cells_for_Python_via_Java_20.2/example.py"
Traceback (most recent call last):
  File "org.jpype.JPypeContext.java", line 330, in org.jpype.JPypeContext.callMethod
  File "Method.java", line 498, in java.lang.reflect.Method.invoke
  File "DelegatingMethodAccessorImpl.java", line 43, in sun.reflect.DelegatingMethodAccessorImpl.invoke
  File "NativeMethodAccessorImpl.java", line 62, in sun.reflect.NativeMethodAccessorImpl.invoke
  File "NativeMethodAccessorImpl.java", line -2, in sun.reflect.NativeMethodAccessorImpl.invoke0
  File "Class.java", line 264, in java.lang.Class.forName
  File "Class.java", line -2, in java.lang.Class.forName0
  File "ClassLoader.java", line 357, in java.lang.ClassLoader.loadClass
  File "ClassLoader.java", line 424, in java.lang.ClassLoader.loadClass
  File "org.jpype.classloader.JPypeClassLoader.java", line 125, in org.jpype.classloader.JPypeClassLoader.findClass
  File "ClassLoader.java", line 530, in java.lang.ClassLoader.findClass
Exception: Java Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\jpype\imports.py",
line 200, in find_spec
    cls = _jpype.JClass("java.lang.Class").forName(name)
java.lang.ClassNotFoundException: java.lang.ClassNotFoundException: com.aspose

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "d:/Aspose Works/Aspose.Cells_for_Python_via_Java_20.2/example.py", line 4, in <module>
    from asposecells.api import Workbook, CellsHelper, FileFormatType, License
  File "d:\Aspose Works\Aspose.Cells_for_Python_via_Java_20.2\asposecells\api.py", line 10, in <module>
    from com.aspose.cells.wrapper import StreamBuffer
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python38\lib\site-packages\jpype\imports.py",
line 204, in find_spec
    raise ImportError("Failed to import '%s'" % name) from ex
ImportError: Failed to import 'com.aspose'

@codinggeek,

Thanks for the details.

It looks like JPype version issue. The more recent or very older versions might have issues when working with Aspose.Cells for Python API. We recommend you to use JPype1 version 0.7.0:

Such issues will be fixed in our future releases. As pip command line will install the latest version of jpype, so you have to uninstall the latest version/other version and install the 0.7.0 version specifically.

Let us know if you still find any issue.

@Amjad_Sahi,

It worked. thanks

@codinggeek,

Good to know that it figures out your issue now. In the event of further queries or issue, feel free to write us back, we will be happy to assist you soon.