Open kamranabbas20 opened 2 years ago
I have the same issue but on macOS and without the custom template. As soon as I build a binary file to run this in a terminal window, I get these errors:
Traceback (most recent call last):
File "PP_Report_Gen.py", line 184, in
It looks like that the pyhton-pptx is looking for a default template. (/pptx/templates/default.pptx) If you could tell me where this file is located or how I can tell the program where to find it, that would be awesome.
OK, I found the solution: Iin the folder where I have the python script, I created a new folder called pptxTemplate In my code I use this to locate the template:
template_path = os.path.dirname(os.path.abspath(__file__))
source_folder = os.path.join(template_path, "pptxTemplate")
template_file_path = os.path.join(source_folder, "ocuair_template.pptx")
In my def, where I create the PowerPoint, I use this:
presentation = Presentation(template_file_path)
When I compile the program I use the following command:
pyinstaller PP_Report_Gen.py \
--onefile \
--add-data="./pptxTemplate:pptxTemplate" \
--target-arch universal2 \
-n ppt-generator
Now the program works on both CPUs, Intel and Apple Silicon.
I hope this helps.
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:
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 thesite-packages
as follows: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?