By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,034 Members | 2,000 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,034 IT Pros & Developers. It's quick & easy.

how to change current working directory while using pdb within emacs

P: n/a
I have written a pyhton script that will process data file in current
working directory.
My script is in an different directory to data file.
When I debug this script using pdb within emacs, emacs will change the
current working directory to the directory which include the script,
so my script cannot find the data file.

I think this is the problem of emacs because when I start pdb from
console directly, it will not change current working directory to the
one of script being debugged.

please help me.
thank you.
Nov 21 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
duyanning wrote:
I have written a pyhton script that will process data file in current
working directory.
My script is in an different directory to data file.
When I debug this script using pdb within emacs, emacs will change the
current working directory to the directory which include the script,
so my script cannot find the data file.

I think this is the problem of emacs because when I start pdb from
console directly, it will not change current working directory to the
one of script being debugged.
Just issue

import os
os.chdir('whatever')

inside the pdb-session. Unfortunate, but should work.

Diez
Nov 21 '07 #2

P: n/a
On Nov 21, 1:28 pm, "Diez B. Roggisch" <de...@nospam.web.dewrote:
duyanningwrote:
I have written a pyhton script that will process data file in current
working directory.
My script is in an different directory to data file.
When I debug this script using pdb within emacs, emacs will change the
current working directory to the directory which include the script,
so my script cannot find the data file.
I think this is the problem of emacs because when I start pdb from
console directly, it will not change current working directory to the
one of script being debugged.

Just issue

import os
os.chdir('whatever')

inside the pdb-session. Unfortunate, but should work.

Diez
thank you! my friend.
Nov 26 '07 #3

P: n/a
duyanning <du*******@gmail.comwrites:
I have written a pyhton script that will process data file in current
working directory.
My script is in an different directory to data file.
When I debug this script using pdb within emacs, emacs will change the
current working directory to the directory which include the script,
so my script cannot find the data file.

I think this is the problem of emacs because when I start pdb from
console directly, it will not change current working directory to the
one of script being debugged.

please help me.
thank you.
pydb (http://bashdb.sf.net/pydb) has an option to set the current
working directory on invocation. For example, from emacs I can run:

M-x pydb --cd=/tmp --annotate=3 ~/python/hanoi.py 3

And then when I type
import os; os.getcwd()

I get:
'/tmp'

Inside pydb, there is a "cd" command saving you the trouble of
importing os; the "directory" command can be used to set a search path
for source files. All same as you would do in gdb.

Begin digression ---

The --annotate option listed above, is similar to gdb's annotation
mode. It is a very recent addition and is only in CVS. With annotation
mode turned on, the effect is similar to running gdb (gdb-ui.el) in
Emacs 22. Emacs internal buffers track the state of local variables,
breakpoints and the stack automatically as the code progresses. If the
variable pydb-many-windows is set to true, the each of these buffers
appear in a frame.

For those of you who don't start pydb initially bug enter via a call
such as set_trace() or debugger() and do this inside an Emacs comint
shell with pydb-tracking turned on, issue "set annotation 3" same as
you would if you were in gdb.

Nov 27 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.