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.


    Can I use the pyphen module?

    Pythonista
    4
    7
    3757
    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.
    • macmacmac
      macmacmac last edited by macmacmac

      I installed the hyphenation module pyphen from pyphen.org using pip install Pyphen in stash. When I run the simple test below I get a TypeError:coercing to Unicode:need... The module should be 100% pure Python.

      import pyphen
      dic = pyphen.Pyphen(lang='en_EN')
      print( dic.wrap('community', 4)  )
      
      Webmaster4o 1 Reply Last reply Reply Quote 1
      • Webmaster4o
        Webmaster4o @macmacmac last edited by Webmaster4o

        @macmacmac Since it's supposed to be "100% pure Python with no dependencies," why don't you try manually downloading and unzipping the package, just in case it's a problem with StaSh. After that, if you still have the problem, maybe you should file a bug report to the developers of Pyphen. If you don't still have the problem after installing it manually, file a bug report with @ywangd, the developer of StaSh.

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

          Restart Pythonista should fix this (double click home button and swipe up to remove Pythonista from the task list).

          It may due to a previous failed pip command. I am not sure and I cannot reproduce it. But by looking at the code of Pyphen. It tries to import pkg_resources which is part of setuptools. These packages are mocked by stash pip and should be removed once pip finishes. Maybe somewhere in previous runs, somehow they are leaked.

          1 Reply Last reply Reply Quote 1
          • macmacmac
            macmacmac last edited by

            @ywangd: Thanks a lot for the simple solution. Restarting did the trick. Thanks also for writing stash.

            @Webmaster4o : Thanks for the useful advise. For future problems: How do I download, unzip and install a module manually using Pythonista?

            Webmaster4o 1 Reply Last reply Reply Quote 0
            • dgelessus
              dgelessus last edited by

              1. wget <download URL>
              2. If it's a zip file, unzip <filename>, if it's a tar.gz file, tar -xzf <filename>
              3. Inside the extracted folder, you'll usually find a folder (or sometimes a single Python script) with the same name as the module - that is what you need to move/copy to site-packages.
              1 Reply Last reply Reply Quote 1
              • Webmaster4o
                Webmaster4o @macmacmac last edited by

                @macmacmac

                @dgelessus gives a good approach using StaSh. I usually just find the file in Safari, and then use the share sheet to "Run Pythonista Script" and then I've got a script that downloads the URL.

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

                  Thanks for both methods. Very useful to know.

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