Use third-party Libary
#1  Fischchen 02-15-2020, 12:14 PM
Hey guys,
i've been trying to make a simple plugin for calibre which uses the GPIO pins of my Raspberry. I wrote a simple plugin but when it try to import it I get the error message
Python function terminated unexpectedly No module named gpiozero (Error Code: 1) Traceback (most recent call last): File "", line 114, in main File "", line 88, in run_entry_point File "site-packages\calibre\customize\", line 792, in main File "site-packages\calibre\customize\", line 752, in build_plugin File "site-packages\calibre\customize\", line 472, in add_plugin File "site-packages\calibre\customize\", line 61, in load_plugin File "site-packages\calibre\customize\", line 203, in load File "importlib\", line 37, in import_module File "site-packages\calibre\customize\", line 185, in load_module File "calibre_plugins.dummy1.__init__", line 2, in <module>
ImportError: No module named gpioze
Can somebody please help me?!?!? I have to be done with this until next week, so please somebody help me!

Thanks in advance

ps:sorry for my english im german

#2  DaltonST 02-15-2020, 03:09 PM
Calibre knows nothing about anything outside of its ecosystem, so you must make external-to-Calibre files visible to your plugin yourself.

For tiny packages (e.g. a useful python module that you need and perhaps found on Github), you could simply hard-copy it into your plugin's folder to make it a private copy.

Example: from .fuzzywuzzy import fuzz, string_processing, utils

For non-trivial packages, you might try (never needed it myself, so no guarantees) something like this:

import sys
import yourfile

Personally, I would defer any imports until the user invokes an action in to avoid premature allocation and use of memory. In other words, do not import it at the top of Make the user click a pushbutton or cause some other event that requires that the file be imported for the first time before continuing.


Today's Posts | Search this Thread | Login | Register