Open existing pptx file
See original GitHub issuepython-pptx 0.5.7 Python 2.7.8
Currently using
f = open('C:\some_folder\my_file.pptx')
prs = Presentation(f)
f.close()
gives error: File is not a zip file
using
prs = Presentation('C:\\some_folder\\my_file.pptx')
gives error: Package not found at ‘C:\some_folder\my_file.pptx’
full stack traces below:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 3035, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-6-78857122896f>", line 2, in <module>
prs = Presentation(f)
File "C:\Python27\lib\site-packages\pptx\api.py", line 26, in __init__
self._package = Package.open(pkg_file)
File "C:\Python27\lib\site-packages\pptx\package.py", line 44, in open
return super(Package, cls).open(pkg_file)
File "C:\Python27\lib\site-packages\pptx\opc\package.py", line 122, in open
pkg_reader = PackageReader.from_file(pkg_file)
File "C:\Python27\lib\site-packages\pptx\opc\pkgreader.py", line 32, in from_file
phys_reader = PhysPkgReader(pkg_file)
File "C:\Python27\lib\site-packages\pptx\opc\phys_pkg.py", line 102, in __init__
self._zipf = ZipFile(pkg_file, 'r')
File "C:\Python27\lib\zipfile.py", line 770, in __init__
self._RealGetContents()
File "C:\Python27\lib\zipfile.py", line 811, in _RealGetContents
raise BadZipfile, "File is not a zip file"
BadZipfile: File is not a zip file
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 3035, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-7-4fbcdf1972de>", line 1, in <module>
prs = Presentation('C:\\some_folder\\my_file.pptx')
File "C:\Python27\lib\site-packages\pptx\api.py", line 26, in __init__
self._package = Package.open(pkg_file)
File "C:\Python27\lib\site-packages\pptx\package.py", line 44, in open
return super(Package, cls).open(pkg_file)
File "C:\Python27\lib\site-packages\pptx\opc\package.py", line 122, in open
pkg_reader = PackageReader.from_file(pkg_file)
File "C:\Python27\lib\site-packages\pptx\opc\pkgreader.py", line 32, in from_file
phys_reader = PhysPkgReader(pkg_file)
File "C:\Python27\lib\site-packages\pptx\opc\phys_pkg.py", line 32, in __new__
"Package not found at '%s'" % pkg_file
PackageNotFoundError: Package not found at 'C:\some_folder\my_file.pptx'
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Working with Presentations - python-pptx - Read the Docs
Actually, it only lets you make changes to existing presentations; it's just that ... python-pptx can open a presentation from a so-called file-like...
Read more >PowerPoint can't open this file - Microsoft Support
In the Save as type box, choose Presentation (*.ppt). Then select Save. Now that the file is in .ppt format, you can open...
Read more >How to Open a PowerPoint Presentation? [Complete Guide!]
To open or view an existing PowerPoint file, double-click on the file from the folder. Alternatively, open the PowerPoint application.
Read more >PowerPoint 2016: Creating and Opening Presentations
To open an existing presentation: · Select the File tab to go to Backstage view, then click Open. Clicking Open · Click Browse....
Read more >How to Open a PPT File Without Powerpoint
Click the “Open Existing Presentation” radio button and then click “Open.” Browse to where your PPT file is located and click “Open” to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
gives error when the presentation is EMPTY, there are 0 slides. adding at least 1 slide with empty content fixes the problem, and it is possible to open such presentation
For the first method, using a file-like object, you need to open the file in binary mode:
Not sure why the second one (using the file path) failed though - double-check that the file exists?