Compatibility with PyInstaller and cx_Freeze

Compatibility with PyInstaller and cx_Freeze

‘Aspose.Slides for Python via .NET’ extensions are simply Python C-extensions, which can be frozen with the help of PyInstaller and cx_Freeze (or similar tools) as program dependencies. This means that you can use tools like PyInstaller and cx_Freeze to create executable files from your Python scripts. These tools are called freezers because they freeze your code and dependencies into a single file that can run on other machines without requiring Python or other libraries. This makes it easier to distribute your Python applications to others.

Freezing an ‘Aspose.Slides for Python via .NET’ extension as a program dependency is illustrated with an example of a simple program that uses Aspose.Slides.


Generally, nothing special needs to be done when packaging a program that depends on a ‘Aspose.Slides for Python via .NET’ extension. When a program imports an extension in a way that is visible to PyInstaller, the extension will be packaged along with the program. Since ‘Aspose.Slides for Python via .NET’ extensions come with PyInstaller hooks, their own dependencies will be found and copied into the bundle.

import aspose.slides as slides

with slides.Presentation() as presentation:
    slide = presentation.slides[0]
    slide.shapes.add_auto_shape(slides.ShapeType.LINE, 50.0, 150.0, 300.0, 0.0)"NewPresentation_out.pptx", slides.export.SaveFormat.PPTX)
$ pyinstaller

However, sometimes PyInstaller cannot detect some hidden imports, which are modules that are imported dynamically or indirectly by your code. To handle a hidden import in PyInstaller, use PyInstaller’s options. The dependencies of an extension are specified in PyInstaller hooks that come with the ‘Aspose.Slides for Python via .NET’ extension.


a = Analysis(
$ pyinstaller slide_app.spec


To freeze a program using cx_Freeze, use its options to freeze the root package of the ‘Aspose.Slides for Python via .NET’ extension that you are using. This will ensure that the extension and the modules it depends on are copied with the program.

Using the cxfreeze script

$ cxfreeze --packages=aspose

Using the Setup script

executables = [Executable('')]

options = {
    'build_exe': {
        'packages': ['aspose'],


$ python build_exe