Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 05-31-2025, 09:48 PM   #1
Rushdie1234
Member
Rushdie1234 began at the beginning.
 
Posts: 17
Karma: 10
Join Date: May 2025
Device: Kindle
Unhappy python / calibre-debug / venv

It feels like a catch-22, but if you use the calibre api it requires its own binary (calibre-debug) and yet to code in a virtual environment (venv), you also have to use a specific binary, in this case the python binary created in the venv. Is it possible to use the calibre database within python within a virtual environment? Am I missing something maybe?

Any help would be appreciated.
Rushdie1234 is offline   Reply With Quote
Old 05-31-2025, 10:13 PM   #2
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: 45,355
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Why do you want to use a venv? calibre contains its own isolated python already. Simply use it. If you want to import some other packages, then add the path to them to sys.path before importing them.
kovidgoyal is offline   Reply With Quote
Old 05-31-2025, 10:22 PM   #3
Rushdie1234
Member
Rushdie1234 began at the beginning.
 
Posts: 17
Karma: 10
Join Date: May 2025
Device: Kindle
Quote:
Originally Posted by kovidgoyal View Post
Why do you want to use a venv? calibre contains its own isolated python already. Simply use it. If you want to import some other packages, then add the path to them to sys.path before importing them.
Well installing libraries is usually done within a venv, not system wide. So how does that work? I can't install a library legitimately without venv. (Not really.)

Again, I could be missing something.
Rushdie1234 is offline   Reply With Quote
Old 05-31-2025, 10:28 PM   #4
Rushdie1234
Member
Rushdie1234 began at the beginning.
 
Posts: 17
Karma: 10
Join Date: May 2025
Device: Kindle
Say, for instance I wanted to use eBookLib. To insall that, I use pip, but to do that I need to be within a venv. Pip won't let me install system-wide unless I break with security.
Rushdie1234 is offline   Reply With Quote
Old 05-31-2025, 10:41 PM   #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: 45,355
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Why on earth would you want to use ebooklib with calibre, calibre contains far more capable code to read ebook formats. And no you dont need to install using venv, venv is just a crutch for people that dont take the time to understand how python importing works. Just download ebooklib wheel and add the path to the wheel to sys.path and then import it. Or unzip the whl file and add the path to the top level directory containing the top level __init__.py to sys.path and import it.
kovidgoyal is offline   Reply With Quote
Old 05-31-2025, 10:50 PM   #6
Rushdie1234
Member
Rushdie1234 began at the beginning.
 
Posts: 17
Karma: 10
Join Date: May 2025
Device: Kindle
Quote:
Originally Posted by kovidgoyal View Post
Why on earth would you want to use ebooklib with calibre, calibre contains far more capable code to read ebook formats. And no you dont need to install using venv, venv is just a crutch for people that dont take the time to understand how python importing works. Just download ebooklib wheel and add the path to the wheel to sys.path and then import it. Or unzip the whl file and add the path to the top level directory containing the top level __init__.py to sys.path and import it.
I don't want to use ebooklib. That was just an example of an external library. There could be a thousand libraries I need in a given script.

But yes, I understand. Just manually download and include the library in the project folder and then add to sys.path. That makes sense.

I would argue though that pip isn't a crutch for the clueless, as you implied. It seems elegant and efficient to me.

But thank you for the help.
Rushdie1234 is offline   Reply With Quote
Old 06-01-2025, 12:22 AM   #7
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: 45,355
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you think the python packaging ecosystem is elegant I urge you to google problems with python packaging.
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to debug calibredb error using Python tools? plo233 Development 1 07-01-2019 12:39 PM
3.34 calibre-debug runs the script code under Python 3 EbokJunkie Conversion 2 11-20-2018 07:43 PM
Python newbie, need help about print statement debug TonyAn Calibre 3 05-17-2017 03:46 PM
How to setup Python debug environment for Calibre Recipes huang5307 Recipes 9 03-03-2016 02:35 PM
win7-debug-python jaapx Calibre 2 10-23-2015 12:11 AM


All times are GMT -4. The time now is 07:32 PM.


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