![]() |
Error on using numpy package into plugin
Hi,
I am writing a plugin which use numpy python package. But everytime I got this error: Quote:
Has anyone an idea or help me please? Thank you |
Numpy is not part of Sigil's bundled python environment. So any plugin wanting to use it would need to include it with the plugin (no idea how one might pull that off), or use an external python environment for Sigil plugins that already had numpy properly installed. Properly installing numpy in an external python environment would likely be a numpy question rather than a Sigil one.
The real question is: what do you need to do to an epub that could possibly require a scientific computing module like NumPy? |
Thank you.
I had include numpy package and other required packages into my plugin package but got the same error. If I use local python interpreter then its works. But the packages whick I inlcuded are from the same python directory. The user of the plugin should be able to use it with the sigil bundled python and included packages. Therefore I need a solution. The plugin which I write is to render Latex math formulas notation into mathml. To display the rendered formulas with symbols I need matplotlib package and matplotlib need numpy. |
I'm assuming you're creating an input plugin then? Otherwise, a sigil plugin won't help you render/display anything.
As to how to package numpy/matplotlib to work in Sigil's bundled python environment, I'm afraid I can't help. I suspect that would be relatively complicated (not to mention large) to accomplish. Pure Python modules are fairly easy to relocate/include. Binary packages can be quite involved and include hardcoded paths or environment variables necessary to function properly. Also note that it's not likely your plugin would work on all Sigil platforms (Windows, OSX, Linux). If installed via pip or your package manager (or other binary media), your compiled modules are going to be platform specific. The binary wheels are also usually specific to a particular Python version. So even if you manage to get something working with Sigil's bundled Python, it's likely to break when we upgrade the version of python that we bundle. For binary dependencies, it's simply going to be best to use an external, python interpreter to run the plugin. That way, you can have your users install the binary dependencies. |
Thank you for your quick reply.
Yes is it an input plugin. I am trying some solutions but not works. Another way is to display on QWebEngineView. Is QtWebEngineWidgets part of sigil bundled python environment? May be not I got this error: Quote:
Thank you |
Quote:
Sigil's plugin framework was never intended to be able to do a lot of high-level rendering. We've only included enough modules for people to do some basic Widgets (PyQt and Tkinter) to utilize in gui interfaces intended to get user input for their plugins' parameters. Quote:
|
Quote:
IIRC, there are also some Python packages and standalone PostScript/LaTex/MathML to SVG converters that you could use, if you don't want to support epub3 books. (Many epub2 apps support SVG images.) |
Thank you
Yes It is better to transfer mathml into svg and display. Now I am searching for a python module for that. Thank you for your quick replies. |
Quote:
There's also these two answers on the LaTeX Stack Exchange that cover some other tools: https://tex.stackexchange.com/questi...mathml-and-tex https://tex.stackexchange.com/questi...and-approaches (tex4ht converts LaTeX -> HTML, and very customizable.) Quote:
Or I personally go LaTeX -> PDF -> SVG+PNG. I wrote about that most recently in this topic. (Also, if you check out the ebookcraft 2018 "Equations in Ebooks" slides, you may get some more methods/ideas too.) If you're putting this book up for sale on the major retailers, you have to keep in mind the millions of older devices out there that can't read/render MathML, so you must design these image fallbacks anyway. Can't rely on purely MathML, which is a shame. |
Thank you.
I already use some python modules to convert latex and asciimath into mathml and it works fine. (Modules: latex2mathml and asciitomathml). What I need is a python module to convert the mathml into svg or any images to display the rendered mathml. The user should be able to see the rendered formula before she/he can add it into the book. What I had used is with matplotlib module: Quote:
I did not find a suitable python module to write mathml into svg which can I load into QSvg to display it. |
Thank you
I found a workaround: - transform latex formulas into png Quote:
|
| All times are GMT -4. The time now is 08:57 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.