omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    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)

    Pythonista
    pip
    3
    7
    2944
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • deloriel42
      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..

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        Two ways i have seen this problem:

        1. 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

        2. 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.

        1 Reply Last reply Reply Quote 1
        • deloriel42
          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.

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • deloriel42
              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

              1 Reply Last reply Reply Quote 0
              • JonB
                JonB last edited by

                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
                https://github.com/cclauss/pythonista-module-versions

                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.

                1 Reply Last reply Reply Quote 0
                • ccc
                  ccc last edited by

                  Pyto has lxml builtin but it is a different app. https://pyto.readthedocs.io/en/latest/

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors