How to override site-packages?
Among my regular Pythonista scripts I have an html2text folder with an
import html2textnever uses it because
PythonistaKit.framework/pylib/site-packages/html2text.pyexists. How do I override it?
sys.pathseems correct. Killing the app didn't help. (Is there a nicer way to restart the interpreter?)
omz last edited by
You could modify
sys.pathbefore importing your own
html2text, but I'd actually recommend just using a different name for your package.
sys.pathalready includes the document folder as the first entry, but Python prioritizes modules over packages.
I can't rename it because it consists of several modules that import each other.
It's not my package but the current (less broken) version of the same repository as is included with Pythonista.
omz last edited by omz
I just tried this – I created an
html2textfolder with an
__init__.py, and it imported just fine. What didn't work was to import
html2text(the built-in version) first, and then trying to create my own package. In that case, the cached built-in module was used. To deal with that, you might want to use something like
del sys.modules['html2text']to force reloading the module from disk.
Btw, which version of Pythonista are you using, and if it's 3.0, which version of Python (2.7 or 3.5)?
Wouldn't killing the app accomplish the reloading?
I renamed the package and changed all the internal imports to html3text, and have a working script now.
It's Pythonista 2. I bought 3 but haven't gotten around to switching.
The problem is that the built-in html2text can't deal with missing CSS definitions, which affects pretty much every page on the web, unless you implement your own handling of