ImportError: Failed to import ‘com.aspose’ after building exe in python 3.11.1

390 Views Asked by At

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.The line that generates the exception and the exception are given below.

exception code

My dependencies: Python = 3.11.1 aspose-cells=23.1.0 JPype1=1.4.1

1

There are 1 best solutions below

0
Amjad Sahi On

Could you please refer to the following steps if it works:

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

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

PS. I am working as Support developer/ Evangelist at Aspose.