An Emacs mode for editing Python code

python-mode loses track of current directory

Reported by Richard Stanton on 2012-08-07
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
High
Andreas Roehler

Bug Description

Using r1055 with Emacs 24.1 under OS X, I'm having trouble with python-mode losing track of the current directory.

For example, I'm trying to run the following script, which reads in a file in the same directory as the script file.

from pandas import *
df = read_csv('test.csv',index_col=0, parse_dates=False)

If I open this file in Emacs, then open an ipython buffer with C-c !, then type "ls" at the resulting ipython prompt, I get a display of the contents of the (correct) directory, including the file test.csv.

Now, if I go back to the script buffer and press C-c C-c, the file is run (through the same ipython buffer), but reports an error

IOError: [Errno 2] No such file or directory: 'test.csv'

If I then type "ls" at the next ipython prompt, it shows me the contents of my HOME directory - not what I want.

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
importance: Undecided → High
milestone: none → 6.1.0
Changed in python-mode:
milestone: 6.0.11 → 6.0.12
Changed in python-mode:
milestone: 6.0.12 → 6.1.0
Andreas Roehler (a-roehler) wrote :

see commit-message, resp. NEWS

Changed in python-mode:
status: New → Fix Committed

To me it does not seem to be corrected. Using r1152 on Linux on emacs 24.1.1, I still get the same problem.

import os
print(os.getcwd())

Give me my home directory on emacs, whereas I got the right thing on a shell. Also if I import something that is in the same directory, I got a :

File "<stdin>", line 1, in <module>
  File "/usr/tmp/python3-11332kaK.py", line 4, in <module>
    from probleme16 import *
ImportError: No module named probleme16

I hope I do not make you lose time with a stupid mistake.

Changed in python-mode:
status: Fix Committed → New
Andreas Roehler (a-roehler) wrote :

presently py-use-current-dir-when-execute-p might be customized to non-nil, which should DTRT

Beside you may specify a py-execute-directory - form has a bug presently, fix follows.

If both are nil, $HOME is used

Please tell if setting this will do it, otherwise I may change it.

Maybe py-use-current-dir-when-execute-p should default to non-nil?

Changed in python-mode:
status: New → Fix Committed
Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers