01-15-2019, 08:15 AM | #1 | |
Member
Posts: 17
Karma: 10
Join Date: Jul 2017
Device: epub
|
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 |
|
01-15-2019, 10:45 AM | #2 |
Grand Sorcerer
Posts: 27,970
Karma: 198535232
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
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? Last edited by DiapDealer; 01-15-2019 at 10:51 AM. |
Advert | |
|
01-16-2019, 05:19 AM | #3 |
Member
Posts: 17
Karma: 10
Join Date: Jul 2017
Device: epub
|
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. |
01-16-2019, 06:38 AM | #4 |
Grand Sorcerer
Posts: 27,970
Karma: 198535232
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
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. Last edited by DiapDealer; 01-16-2019 at 06:47 AM. |
01-16-2019, 07:23 AM | #5 | |
Member
Posts: 17
Karma: 10
Join Date: Jul 2017
Device: epub
|
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 |
|
Advert | |
|
01-16-2019, 08:39 AM | #6 | |
Grand Sorcerer
Posts: 27,970
Karma: 198535232
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
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. To put it quite bluntly: you can't. Sorry. Sigil plugins were not intended to be used to display content. They're intended to import/edit/validate/export content. Last edited by DiapDealer; 01-16-2019 at 08:42 AM. |
|
01-16-2019, 09:49 AM | #7 | |
Grand Sorcerer
Posts: 5,636
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
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.) |
|
01-19-2019, 03:31 AM | #8 |
Member
Posts: 17
Karma: 10
Join Date: Jul 2017
Device: epub
|
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. |
01-19-2019, 11:44 AM | #9 | |
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
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.) You could use some of the above tools to LaTeX -> MathML, and then go MathML -> SVG+PNG. 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. Last edited by Tex2002ans; 01-19-2019 at 11:48 AM. |
|
01-22-2019, 08:25 AM | #10 | |
Member
Posts: 17
Karma: 10
Join Date: Jul 2017
Device: epub
|
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. |
|
01-29-2019, 05:25 AM | #11 | |
Member
Posts: 17
Karma: 10
Join Date: Jul 2017
Device: epub
|
Thank you
I found a workaround: - transform latex formulas into png Quote:
|
|
Tags |
mathml, multiarray, numpy, plugin |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using wordpress_xmlrpc package in my plugin | wrench100 | Development | 4 | 08-17-2018 07:17 PM |
iTunes Producer "package.opf" error | MatMu | ePub | 3 | 11-19-2017 07:05 PM |
Multi-plugin package | jgoguen | Development | 5 | 05-25-2015 04:21 PM |
Calibre plugIn Kindle Collections Error message "Value Error:month..." | readee | Plugins | 4 | 10-10-2011 11:21 AM |
PRS-505 Error: package.opf is over 300KB | papilonv | Sony Reader | 1 | 09-17-2010 07:18 AM |