I have a python script that I want to debug with python-mode. I read in this thread that I can debug my python script with M-x pdb, however I get the following error:
Searching for program: no such file or directory, pdb
I can provide python -m pdb my_source_file.py in the prompt in the minibuffer, but it would be nice if Emacs could infer this command directly from the file on which I run M-x pdb
Update:
Running on:
- Red Hat Enterprise Linux Server release 5.1 (Tikanga)
- Emacs 23.3.1
Differences between paths
I get different paths when I run M-: exec-path and when I run M-: (getenv "PATH") (the one returned by M-: (getenv "PATH") is longer).
With this:
- Where is
pdblocated? How can I add it to the Emacs path? - Is there a way to ask Emacs to also look into the paths held by the environment variable
PATH?
Further to my comment earlier, and your subsequent update to the question:
First figure out a value for
$PATHthat works in your terminal. Usewhich pdbto find where thepdbexecutable is located.Then, set the
$PATHenvironment variable explicitly in Emacs, and sync it toexec-pathas follows:It’s possible you would need to also explicitly set
PYTHONPATHor similar environment variables; you can do that using lines like the “setenv” line above, or just use the exec-path-from-shell elisp package.Update
Okay, so it turns out Emacs’
pdbcommand isn’t provided bypython-mode, and it expects to find an executable called “pdb”. The easy way to fix this, then is to create a shell wrapper called “pdb”, in a directory on your $PATH:(I found a note here suggesting this technique.)
The equivalent under Windows would be a file called pdb.bat, containing:
(The
-uprevents Python from buffering its output.)