• variant1: the most minimalist approach works but imho it is very primitive 🙂 (but it works)
  • variant2: a wee bit better

let’s go

hostnamectl; # tested with
Virtualization: kvm
Operating System: Ubuntu 22.04.4 LTS 
Kernel: Linux 5.15.0-94-generic
Architecture: x86-64

# variant1: the very primitive
# test pdb installed
pdb3

# create new file
vim test.debug.py

# fill with
import pdb
def main():
  list = [1,2,3]
  pdb.set_trace()
  list = [2,3,4]

if __name__ == '__main__':
    main()
# then while still in vim
:!python3 %

# this will give this:

btw pdb3 is just a python script

which pdb3 /usr/bin/pdb3 -but-this-is-just-a-link-> /usr/bin/pdb3.10 -which-again-links-to-> /usr/lib/python3.10/pdb.py* # which is a python script vim /usr/lib/python3.10/pdb.py # which belongs to this package dpkg -S /usr/lib/python3.10/pdb.py libpython3.10-stdlib:amd64: /usr/lib/python3.10/pdb.py

# variant2 the a bit less primitive Termdbg ipdb3
# as non root user
# clone into ~/.vim
git clone https://github.com/epheien/termdbg ~/.vim
# now open
# background check:
# a search
apt search python|less
# then search output of the search like
/pdb
# reveals
python3-ipdb/jammy 0.13.9-1 all IPython-based pdb replacement (Python 3 version)

apt install python3-ipdb

# open a test file
vim debug.this.py

# then enter
Termdbg ipdb3 debug.this.py

# will give

going all in fancy:

wow: https://200ok.ch/posts/vim-as-python-ide.html

Links:

https://www.vim.org/scripts/script.php?script_id=5769 https://github.com/epheien/termdbg

https://docs.python.org/3/library/pdb.html

debugging python on C level https://wiki.python.org/moin/DebuggingWithGdb

Ubuntu: # btw

if something crashes under Ubuntu a strange popup “pops” up saying “have to report a problem” the info that will be send to Canonical is in here

/var/crash/_usr_lib_python3.10_pdb.py.0.crash

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin