scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.37k stars 513 forks source link

ImportError: cannot import name 'Presentation' #775

Closed kindler-king closed 2 years ago

kindler-king commented 2 years ago

I have python==3.6.7 installed and after doing pip install python-pptx, I am still getting an error

from pptx import Presentation ImportError: cannot import name 'Presentation' from 'pptx' (d:\pptx\PowerPointless\pptx.py)

when trying to run a script from the documentation. Would appreciate any suggestion to fix the error. Note: I have tried using virtual env too.

scanny commented 2 years ago

If you have a module in your working directory named pptx (like pptx.py), then Python is trying to import Presentation from there. Local modules get precedence over library modules when Python is locating which module to import.

You'll need to change your module name to something else, like my_pptx.py or perhaps something more descriptive :)

kindler-king commented 2 years ago

Thanks a lot for the insight @scanny great work. I missed something so simple while trying out pptx. Thanks for the help.