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?
-
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) )
-
@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.
-
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.
-
@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?
-
wget <download URL>
- If it's a zip file,
unzip <filename>
, if it's a tar.gz file,tar -xzf <filename>
- 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
.
-
@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.
-
Thanks for both methods. Very useful to know.