Skip to content

Embedding custom pptx template within executable file #804

@kamranabbas20

Description

@kamranabbas20

I have written a code that takes several pictures from a folder and collates them into a company-specific PowerPoint template. Within the code, I am indicating the location of the template, which is in the same directory as the .py file. However, upon creating a .exe file it results in an error in the line that specifies the template of the presentation:

template = os.getcwd() + '\\template.pptx'
prs = Presentation(template) ### ERROR OCCURS HERE

Is there a way to embed my own power point template while building .exe file. I have tried putting it into .spec file, by indicating the location of the custom pptx template in datas, which I put into the site-packages as follows:

Screenshot_1

p = "C:\\Users\\<username>\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages\\pptx\\templates\\my_template.pptx"

block_cipher = None

a = Analysis(['Pictures_to_Slides.py'],
         pathex=[],
         binaries=[],
         datas=[ (p, '.\\pptx\\templates\\') ],
         hiddenimports=[],
         hookspath=[],
         hooksconfig={},
         runtime_hooks=[],
         excludes=[],
         win_no_prefer_redirects=False,
         win_private_assemblies=False,
         cipher=block_cipher,
         noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
         cipher=block_cipher)

After doing this the .exe file was created successfully but again resulted in error at the stage of declaring Presentation("my_template.pptx)

Does anybody have an experience with building custom pptx templates within .exe files?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions