After installing pptx on python and running the following sample
from pptx import Presentation
prs=Presentation()
title_slide_layout=prs.slide_layouts[0]
slide=prs.slides.add_slide(title_slide_layout)
title=slide.shapes.title
title=slide.placeholders[1]
title.text="Hello, World!"
title.text="python-pptx was here!"
prs.save('test.pptx')
The following error occurred:
Traceback (most recent call last):
File "C:\Users\XXXX\Desktop\python\pptx.py", line 1, in <module>
from pptx import Presentation
File "C:\Users\XXXX\Desktop\python\pptx.py", line 1, in <module>
from pptx import Presentation
ImportError: cannot import name 'Presentation'
(base) C:\Users\XXXX\Downloads> pip show python-pptx
As I checked in , it seems to have been installed.
Name: python-pptx
Version: 0.6.9
Summary: Generate and manage Open XML PowerPoint (.pptx) files
Home-page: http://github.com/scanny/python-pptx
Author: Steve Canny
Author-email: [email protected]
License: The MIT License (MIT)
Location: c:\users\XXXX\appdata\local\continuum\anaconda3\lib\site-packages
Requirements: Pillow, lxml, XlsxWriter
The folder was also found below.
C:\Users\XXXX\AppData\Local\Continuum\anaconda3\Lib\site-packages\pptx
The version is
Python 3.6 version
python-pptx0.6.9
Thank you for your cooperation.
python python3
If you have saved the sample you are trying to run under the filename pptx.py
, remove pptpx.py
and pptx.pyc
from Desktop\pyhon\
.
from pptx import presentation
is probably an error because the from pptx
points to the sample code itself.
Traceback (most recent call last):
File "C:\Users\XXXX\Desktop\python\pptx.py", line 1, in
from pptx import Presentation
File "C:\Users\XXXX\Desktop\python\pptx.py", line 1, in
from pptx import Presentation
ImportError: cannot import name 'Presentation'
The error message indicates that "C:\Users\XXXX\Desktop\python\pptx.py" does not contain 'Presentation'.
Installed
not "C:\Users\XXXX\Desktop\python\pptx.py"
If you set it to import from "c:\users\XXXX\appdata\local\continuum\anaconda3\lib\site-packages\python-pptx", it will be solved.
(All you need to do is delete the file "C:\Users\XXXX\Desktop\python\pptx.py")
© 2025 OneMinuteCode. All rights reserved.