Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 02-06-2018, 09:53 AM   #1
tsar2512
Junior Member
tsar2512 began at the beginning.
 
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
tsar2512 is offline   Reply With Quote
Old 02-06-2018, 10:05 AM   #2
tsar2512
Junior Member
tsar2512 began at the beginning.
 
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.
tsar2512 is offline   Reply With Quote
Old 02-06-2018, 11:08 AM   #3
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,748
Karma: 22446736
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
kovidgoyal is online now   Reply With Quote
Old 02-06-2018, 11:24 AM   #4
tsar2512
Junior Member
tsar2512 began at the beginning.
 
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.
tsar2512 is offline   Reply With Quote
Old 02-06-2018, 11:52 AM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,748
Karma: 22446736
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
kovidgoyal is online now   Reply With Quote
Old 02-06-2018, 12:00 PM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,748
Karma: 22446736
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by tsar2512 View Post
I understand that I can hack calibre by modifying and adding my own python code there.
And you are not hacking calibre in the scenario I posted, you are running your python script using the python interpreter bundled with calibre.
kovidgoyal is online now   Reply With Quote
Old 02-06-2018, 12:05 PM   #7
tsar2512
Junior Member
tsar2512 began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2018
Device: ipad
understood!
tsar2512 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 06:58 AM.


MobileRead.com is a privately owned, operated and funded community.