09-29-2020, 03:37 AM | #1 |
Junior Member
Posts: 2
Karma: 10
Join Date: Sep 2020
Device: none
|
Help me start a debugging session with pudb
This is not a question about pudb specifically, I am more interested in figuring out why Python doesn't see the module I installed.
Hello. My goal is to debug calibre with external debugger https://documen.tician.de/pudb/starting.html I insert breakpoint here: https://github.com/kovidgoyal/calibr...ug/main.py#L45 Breakpoint looks like this: Code:
import pudb; pu.db Code:
calibre-debug main.py -- /path/to/ebook.mobi Code:
Traceback (most recent call last): File "runpy.py", line 194, in _run_module_as_main File "runpy.py", line 87, in _run_code File "site.py", line 48, in <module> File "site.py", line 44, in main File "/home/paulriddle/code/calibre/src/calibre/debug.py", line 336, in main run_script(args[1], args[2:]) File "/home/paulriddle/code/calibre/src/calibre/debug.py", line 243, in run_script exec_path(ef, g) File "/home/paulriddle/code/calibre/src/polyglot/builtins.py", line 110, in exec_path exec(code, ctx) File "/home/paulriddle/code/calibre/src/calibre/ebooks/mobi/debug/main.py", line 51, in <module> main() File "/home/paulriddle/code/calibre/src/calibre/ebooks/mobi/debug/main.py", line 46, in main import pudb; pu.db ModuleNotFoundError: No module named 'pudb' Code:
1. pip install --user pudb 2. pip install pudb 3. pipx install pudb I set Code:
CALIBRE_DEVELOP_FROM=/home/paulriddle/code/calibre/src Python 3.8.5 |
09-29-2020, 06:53 AM | #2 |
creator of calibre
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The calibre binaries come with their own private python. If you want to import an external package you have to insert the path to that package into sys.path
|
09-29-2020, 07:45 AM | #3 |
Junior Member
Posts: 2
Karma: 10
Join Date: Sep 2020
Device: none
|
Thank you for the reply. I don't know about sys.path editing, but I managed to get it working another way. Instead of installing calibre via binary installer, I used my system package manager, pacman. Then I installed pudb with pip install pudb. For some reason it didn't ask for root permissions, but ok. Then I could insert breakpoints with import pudb; pu.db and it worked.
Anyways, knowing that calibre ships with it's own python gives me a clue of where to look when issues arise. |
09-30-2020, 01:05 PM | #4 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
As Kovid said, if you use the binary installer it's more complicated to add additional modules. But also if you're going to use the [community] package then you might as well also use https://www.archlinux.org/packages/c...y/python-pudb/
Don't ever use pipx. Pipx is intended for creating one virtualenv for each module you install, the virtualenv contains copies of every dependent module and in order to add the library path you need to run the module using pipx. It's an unwisely created piece of software which is basically "docker for python" and it doesn't interoperate with anything else anywhere ever. "pip install pudb" would work fine, by default pip does a local user install (as if you specified pip install --user pudb) for precisely the issue of you should not need root for this. Note that for the distro binaries rather than the official prebuilt binaries, you will want to override the source code using "export CALIBRE_PYTHON_PATH" rather than CALIBRE_DEVELOP_FROM. |
10-01-2020, 08:50 AM | #5 |
Zealot
Posts: 100
Karma: 10
Join Date: Aug 2019
Device: none
|
https://www.mobileread.com/forums/sh...d.php?t=228173
may be helpful to show how to import an external package you have to insert the path to that package into sys.path |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Session Timeout | Pizza_Cant_Read | Feedback | 4 | 11-24-2017 07:07 PM |
V3 does not run in remote session | loviedovie | Calibre | 1 | 06-28-2017 11:26 PM |
Automatically restore last session? | Roboticist | Library Management | 3 | 07-31-2015 12:01 PM |
Update metadata once per session possible? | Ripplinger | Calibre | 0 | 11-24-2012 09:10 PM |
minutes each session? | IxiaAurea | Kobo Reader | 11 | 09-10-2011 10:31 PM |