I have my python setting within my .emacs (23.1.1) file set up as follows:

(setq py-install-directory "~/.emacs.d/python/python-mode.el-6.0.11/")
(add-to-list 'load-path py-install-directory)
(require 'python-mode)

; specify Python and IPython paths
;; (setq py-shell-name "~/anaconda/bin/ipython") ;; Python 2.7
(setq py-shell-name "~/anaconda3/bin/ipython") ;; Python 3.x

; use IPython
;; (setq-default py-shell-name "~/anaconda/bin/ipython") ;; Python 2.7
(setq py-python-command "python3")
(setq-default py-shell-name "~/anaconda3/bin/ipython3") ;; Python 3.2
(setq-default py-which-bufname "IPython")
(setq python-shell-interpreter "ipython"
       python-shell-interpreter-args "-i")
; use the wx backend, for both mayavi and matplotlib
(setq py-python-command-args '("--gui=wx" "--pylab=wx" "-colors" "Linux"))
(setq py-force-py-shell-name-p t)

; switch to the interpreter after executing code
(setq py-shell-switch-buffers-on-execute-p t)
(setq py-switch-buffers-on-execute-p t)
; don't split windows
(setq py-split-windows-on-execute-p nil)
; try to automagically figure out indentation
(setq py-smart-indentation t)

I can open the IPython interpreter via the usual C-c !. Once IPython is open I confirm that the current path is correct:

In [2]: pwd
Out[4]: '/datadrive/Research/'

However, when I run a script that has a relative path within it it fails with the following message:

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-5-6181a388fabf> in <module>()
----> 1 exec(compile(open('/usr/tmp/~-anaconda3-bin-ipython3-31968Yho.py').read(), '/usr/tmp/~-anaconda3-bin-ipython3-31968Yho.py', 'exec')) # PYTHON-MODE

/usr/tmp/~-anaconda3-bin-ipython3-31968Yho.py in <module>()

FileNotFoundError: [Errno 2] No such file or directory: '../datafile.txt'

So, I check the current working directory again and find that it has changed:

In [6]: pwd
Out[6]: '/home/tnknepp'

It seems the file is being copied to a temporary folder (/usr/tmp) and executed from there...which makes no sense. Is there a way to correct this?

Emacs 23.1.1, RHEL6

  • Please load a more recent python-mode.el, it'a available via melpa. Should the bug still occur, please report it at gitlab.com/python-mode-devs/python-mode/issues or at bugs.launchpad.net/python-mode – Andreas Röhler Sep 22 '16 at 17:49
  • I have not been able to get any newer versions to work. My emacs throws errors on startup when I point to a newer version. Is it correct that the 6.0.11 version is the last that supported emacs 23.1? I want to confirm that before submitting a bug report. – tnknepp Sep 22 '16 at 20:22
  • Please report the errors from newer versions requesting backward-compatibility. – Andreas Röhler Sep 23 '16 at 14:54

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.