02-06-2018, 09:53 AM | #1 |
Junior Member
Posts: 9
Karma: 10
Join Date: Feb 2018
Device: ipad
|
Running Calibre CLI module, SYS arguments?
I am trying to run Calibre's CLI module directly in python. After cloning the source code from git, I tried the following:
python -m calibre.ebooks.conversion.cli abc.epub abc.pdf It seems like there are sys. variables being setup in init scripts somewhere, are they being loaded from environment variables? If so, what environment variables do I need to set ? I already have: echo $CALIBRE_DEVELOP_FROM workspace/calibre/src/ The following is the error I get: Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 151, in _run_module_as_main mod_name, loader, code, fname = _get_module_details(mod_name) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 101, in _get_module_details loader = get_loader(mod_name) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 464, in get_loader return find_loader(fullname) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 474, in find_loader for importer in iter_importers(fullname): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 430, in iter_importers __import__(pkg) File "calibre/__init__.py", line 22, in <module> from calibre.startup import winutil, winutilerror File "calibre/startup.py", line 85, in <module> import calibre.utils.resources as resources File "calibre/utils/resources.py", line 67, in <module> _resolver = PathResolver() File "calibre/utils/resources.py", line 18, in __init__ self.locations = [sys.resources_location] AttributeError: 'module' object has no attribute 'resources_location' calibre/ptempfile.py:29: RuntimeWarning: Parent module 'calibre' not found while handling absolute import import shutil |
02-06-2018, 10:05 AM | #2 |
Junior Member
Posts: 9
Karma: 10
Join Date: Feb 2018
Device: ipad
|
As additional information. I run the command from calibre's src directory. After creating a __init__.py in the calibre/src/ directory.
|
Advert | |
|
02-06-2018, 11:08 AM | #3 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You dont run calibre in python, you run python in calibre, see https://manual.calibre-ebook.com/dev...all-of-calibre
|
02-06-2018, 11:24 AM | #4 |
Junior Member
Posts: 9
Karma: 10
Join Date: Feb 2018
Device: ipad
|
I understand that I can hack calibre by modifying and adding my own python code there.
However, in my use-case, I would like to use calibre's ebook-conversion tool using python. Since most of it looks like python code. I would assume that I should be able to run it through the python interpreter? However, I am having difficulties with the resource_locations attribute, which I cannot find exactly where it's being defined in the __init__.py file. |
02-06-2018, 11:52 AM | #5 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You have to install calibre from source for that, and see the next section in the link I posted earlier
|
Advert | |
|
02-06-2018, 12:00 PM | #6 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
02-06-2018, 12:05 PM | #7 |
Junior Member
Posts: 9
Karma: 10
Join Date: Feb 2018
Device: ipad
|
understood!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to get Calibre 3 running on Raspberry Pi 3 running Raspbian Jessie? | fivestones | Calibre | 6 | 01-25-2018 09:41 PM |
Agency (ebook) pricing gone from arguments on MR to arguments in court. | RichL | News | 3 | 12-07-2011 07:40 AM |
Always same problem Calibre - MacBook Air 11 "Not enough arguments for format string" | Beachu | Calibre | 7 | 02-19-2011 01:15 PM |
calibre-debug --update-module | iain_benson | Calibre | 4 | 10-02-2009 07:00 PM |