ModuleNotFoundError: No module named ‘com.aspose’ error while importing from asposecells on ubuntu via Databricks

Assistant: Do you want to include any more details before I generate a support ticket for you.
Pooja: We are running it on an ubuntu machine via Databricks. The complete code snippet is
import jpype
jpype.startJVM()
import asposecells
from asposecells.api import Workbook, FileFormatType, PdfSaveOptions

error was tracked to this -
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 from asposecells.api import Workbook, FileFormatType, PdfSaveOptions
/databricks/python/lib/python3.7/site-packages/asposecells/api.py in
8 from jpype import imports
9
—> 10 from com.aspose.cells.wrapper import StreamBuffer
11 @JImplementationFor(“com.aspose.cells.wrapper.StreamBuffer”)
12 class _StreamBuffer(object):
ModuleNotFoundError: No module named ‘com.aspose’
Assistant: Pooja, one last thing before I move forward. Please provide an appropriate subject line for your support ticket.
Pooja: Module com.aspose not available while importing from asposecells
Assistant: Almost done, generating support ticket for you.
Assistant: Thanks Pooja. I’ve generated a support ticket for you. Someone will get back to you as soon as possible.
Assistant: This is your support ticket url https://forum.aspose.com/t/module-com-aspose-not-available-while-importing-from-asposecells-aspose-assistant-conversation-with-customer-on-wednesday-october-13th-2021-817-am/236420
Pooja: thank you so much
Assistant: :wave:, Pooja! This is Aspose Assistant.
Assistant: May I know what are you looking for?
Pooja: yes, I want to edit the generated ticket to include that the python version is 3.7.3 and, JPype1 version is 1.3.0
Assistant: Hello, Pooja! This is Aspose Assistant.
Assistant: Please let me know how can I help you today?
Pooja: please add the above comment in this ticket Module com.aspose not available while importing from asposecells on ubuntu via Databricks
Assistant: Thanks for asking question. I’ll be forwarding your query to our technical support department.
Assistant: Do you want to include any more details before I generate a support ticket for you.
Pooja: please add the python version is 3.7.3 and, JPype1 version is 1.3.0. In the ticket Module com.aspose not available while importing from asposecells on ubuntu via Databricks.
I have tried to change the JPype1 version to 0.7.0 but, got the same kind of error about ‘com’
Assistant: Pooja, one last thing before I move forward. Please provide an appropriate subject line for your support ticket.
Pooja: Module com.aspose not available while importing from asposecells
Assistant: One moment please, generating support ticket.

@1634112317703,

We have logged an investigation ticket for your issue. We will look into your issue and figure it out soon. The ticket is logged as following:
CELLSPYTHONJAVA-23 - ModuleNotFoundError: No module named ‘com.aspose’ while using Aspose.Cells for Python

Once we have an update on it, we will let you know.

@1634112317703,

We evaluated your issue. We used the following steps to test Aspose.Cells for Python via Java and it works fine.

1). Create a Databricks node, Databricks Runtime Version: 8.3 (includes Apache Spark 3.1.1, Scala 2.12)

2). Select “Libraries” tab, click “Install New” button. In “Install Library” dialog, select “PyPI” tab, input “aspose-cells” and click “Install” button to install Aspose.Cells for Python via Java 21.9.0.

3). Select “Apps” tab, click “Launch Web Terminal” button to open a web terminal.

4). Check versions:
Ubuntu: VERSION=“18.04.5 LTS (Bionic Beaver)”
Python: 3.8.8
Java: openjdk version “1.8.0_282”
aspose-cells: 21.9.0
JPype1: 1.3.0

5). Test JPype1, it works fine.

import jpype
import jpype.imports
from jpype.types import *

jpype.startJVM()
from java.util import ArrayList

myList = ArrayList()
myList.add(1)
myList.add(2)

print('length:', len(myList))

jpype.shutdownJVM()

6). Test aspose-cells, it works fine too.

import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook, FileFormatType

workbook = Workbook(FileFormatType.XLSX)
workbook.getWorksheets().get(0).getCells().get("A1").putValue("Hello World")
workbook.save("output.xlsx")

jpype.shutdownJVM()

7). We also tested on Databricks 7.3 LTS (Scala 2.12, Spark 3.0.1), it works fine too.

Hi, thank you for the investigation.
As mentioned we are using python version is 3.7.3
and, for step 1, the databricks runtime version is 6.4 (includes Apache Spark 2.4.5, Scala 2.11)
Step 2 is exactly replicated as at my end. Also installed JPype1 the same way.
The details for step 4 are -

Distributor ID: Ubuntu
Description: Ubuntu 16.04.7 LTS
Release: 16.04
Codename: xenial

Python: 3.7.3
Assuming Aspose-cells version is the same as you have mentioned as I could not find any variable to check the version from after checking “dir(asposecells)” after “import asposecells” statement in the notebook.
Cannot check Java: openjdk version as well since as the “Launch Web Terminal” is disabled for this cluster I am working on.

Then I ran this command in the notebook:
import jpype
jpype.startJVM()
import asposecells
from asposecells.api import Workbook, FileFormatType, PdfSaveOptions

workbook = Workbook(‘X.xlsx’)
workbook.getWorksheets().get(‘sheet1’)
saveOptions = PdfSaveOptions()
saveOptions.setOnePagePerSheet(True)
workbook.save(“X.pdf”, saveOptions)
jpype.shutdownJVM()

and got this output:
ModuleNotFoundError Traceback (most recent call last)
in
2 jpype.startJVM()
3 import asposecells
----> 4 from asposecells.api import Workbook, FileFormatType, PdfSaveOptions
5
6 workbook = Workbook(‘X.xlsx’)

/databricks/python/lib/python3.7/site-packages/asposecells/api.py in
8 from jpype import imports
9
—> 10 from com.aspose.cells.wrapper import StreamBuffer
11 @JImplementationFor(“com.aspose.cells.wrapper.StreamBuffer”)
12 class _StreamBuffer(object):

ModuleNotFoundError: No module named ‘com.aspose’

@Galena,

We are sorry that you still finds the issue. We have recorded your findings and details. We will evaluate and get back to you.

By the way, you are using older databricks runtime version and we would suggest you to try newer versions if it makes any difference. Also, if possible, could you try to test your scenario/case in the environment similar to ours.

Moreover, could you simply test JPype1 if it works or not?

import jpype
import jpype.imports
from jpype.types import *

jpype.startJVM()
from java.util import ArrayList

myList = ArrayList()
myList.add(1)
myList.add(2)

print('length:', len(myList))

jpype.shutdownJVM()

Hi Amjad
I tested jpype with the snippet you have shared and it works as expected. We are using the specified version of Databricks runtime as well as python because it is part of BAU and, we cannot change that. Could you please try with the same exact specifications.

@Galena,

We tested further. We found there are some differences between notebook and terminal environments. Aspose.Cells for Python via Java works fine on terminal but we got same error in the notebook. We are sorry but we cannot fix such a bug for notebook using Databricks.

Thank you for the investigation.

You are welcome.