This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
weird import error in pptx (python-pptg)
deloriel42 last edited by ccc
after finding the right way to install py3 libraries with stash properly, I am still running in this weird import error in the python-pptx library
Traceback (most recent call last): File "/private/var/mobile/Containers/Shared/AppGroup/D1B77FF7-7126-4C9B-B6FC-0470A3A25828/File Provider Storage/Repositories/md2pptx/md2pptx.py", line 15, in <module> from pptx import Presentation File "/private/var/mobile/Containers/Shared/AppGroup/CB775338-75D0-4D40-BCA3-F31D6F8FFE4C/Pythonista3/Documents/site-packages-3/pptx/__init__.py", line 8, in <module> import pptx.exc as exceptions AttributeError: module 'pptx' has no attribute 'exc'
But in fact it has a exc.py in the pptx folder.
Am I missing something?
Help would be appreciated..
Two ways i have seen this problem:
make sure you dont have any files called pptx.py, anywhere on your path, or a folder called pptx. That includes your main ~/Documents folder (This iPad), as well as site-packages or site-packages-3. The only one should be the actual installed module.
Also check for any .pyc files, and delete those. sometimes pycs get installed, but those wont work
If you started to import, but then hit "X" to cancel, sys.modules gets left in a screwed up state. matplotlib is notorious for this, because the import takes a long time. in that case, simply force quit pythonista, then start fresh.
deloriel42 last edited by
Ok, that helped a little.
I checked and there are no pptx scripts
Restarting Pythonista changes the error to lxml module (I am still looking for that...)
Traceback (most recent call last): File "/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/2020-10/test.py", line 1, in <module> from pptx import Presentation File "/private/var/mobile/Containers/Shared/AppGroup/CB775338-75D0-4D40-BCA3-F31D6F8FFE4C/Pythonista3/Documents/site-packages-3/pptx/__init__.py", line 14, in <module> from pptx.api import Presentation # noqa File "/private/var/mobile/Containers/Shared/AppGroup/CB775338-75D0-4D40-BCA3-F31D6F8FFE4C/Pythonista3/Documents/site-packages-3/pptx/api.py", line 15, in <module> from .package import Package File "/private/var/mobile/Containers/Shared/AppGroup/CB775338-75D0-4D40-BCA3-F31D6F8FFE4C/Pythonista3/Documents/site-packages-3/pptx/package.py", line 11, in <module> from .opc.package import OpcPackage File "/private/var/mobile/Containers/Shared/AppGroup/CB775338-75D0-4D40-BCA3-F31D6F8FFE4C/Pythonista3/Documents/site-packages-3/pptx/opc/package.py", line 13, in <module> from .oxml import CT_Relationships, serialize_part_xml File "/private/var/mobile/Containers/Shared/AppGroup/CB775338-75D0-4D40-BCA3-F31D6F8FFE4C/Pythonista3/Documents/site-packages-3/pptx/opc/oxml.py", line 12, in <module> from lxml import etree ImportError: cannot import name 'etree'
After second call it’s the former error again.
Aww, lxml is not supported in pythonista, so you may be out of luck, unless you edit the modules to use regular xml or beautifulsoup instead of lxml.
deloriel42 last edited by
. Is there a repository or a list about unsupported modules in Pythonista?
So it seems that I have to switch to Pyto for that task. Strange but OK.
@JonB 1000 thanks
i dont think there is an official list of unsupported modules -- anything that relies on c code, that isnt already included in pythonista is unsupported.
A list of modules and their versions included with pythonista can be found here
Anything that is pure py (that doesnt use subprocess, Popen, or a few others), relying on other pure py modules or any of the above generally work.
ccc last edited by
lxmlbuiltin but it is a different app. https://pyto.readthedocs.io/en/latest/