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

Free Support Forum - aspose.com

ImportError: Failed to import 'com.aspose' after building exe in python

Hello, Aspose Team I use Python’s AsposeCells to generate PNG images from excel files. First off, it works properly with my Python code. But I encountered this issue when I tried to turn my script into an exe file with Pyinstaller. I couldn’t come up with a solution for this. Please assist me!

Python == 3.11.1
aspose-cells==23.1.0
JPype1==1.4.1

The code that generates the exception and the exception are attached here.

image.png (20.0 KB)
image.jpg (75.9 KB)

@sanoy414
Please refer to Error occurs after packaging python code to exe

@Nick.Liu I followed all the Steps but still getting this error

image.png (12.0 KB)

For your information, My versions are:

Python == 3.11.1
aspose-cells==23.1.0
JPype1==1.4.1

@sanoy414,

We are sorry that you still could not figure out your issue. We will evaluate it further and may provide more details on it so you could figure out your issue on your end.

We will get back to you soon.

@sanoy414
Please try the below steps:

Create a folder as c:\app, and copy example.py(attached) to c:\app
Now, open your command prompt, type the below commands in the prompt.

  1. cd c:\app

  2. pyinstaller example.py

  3. copy the jars(aspose-cells-23.1.jar, bcprov-jdk15on-160.jar, bcpkix-jdk15on-1.60.jar, JavaClassBridge.jar. They exist in C:\Python311\Lib\site-packages\asposecells\lib folder) to c:\app

  4. edit example.spec to add datas section like below (attached)
    mydatas = [(’./aspose-cells-22.11.jar’, ‘.’),

             ('./bcprov-jdk15on-160.jar', '.'),
    
             ('./bcpkix-jdk15on-1.60.jar', '.'),
    
             ('./JavaClassBridge.jar', '.') ]
    

a = Analysis(

['example.py'],

pathex=[],

binaries=[],

datas=mydatas,

hiddenimports=[],

hookspath=[],

hooksconfig={},

runtime_hooks=[],

excludes=[],

win_no_prefer_redirects=False,

win_private_assemblies=False,

cipher=block_cipher,

noarchive=False,

)

  1. pyinstaller example.spec
  2. cd c:\app\dist\example
  3. example.exe

I use the same versions of python aspose-cells jpype1 as you.example.zip (1.1 KB)