2

I'm using ubuntu 14.04, emacs 24.3.1, python 2.7.6, ipython 1.2.1, python-mode 6.1.3. Ipython has been working well within emacs for at least a year, however, I have the following problem since two weeks ago.

  1. use C-c! to start default interpreter, ipython shows as I hoped, but instead of split frame and show in another window, it appears in the original code window. (this is a minor problem)
  2. use C-c| to execute a region, python interpreter starts, and the code sends to the python interpreter instead of ipython interpreter

I searched on SO, but this problem seems too recent to have an answer. I googled, found this page https://answers.launchpad.net/python-mode/+question/250905, tried methods therein, still didn't work... Could anyone help me fix the problem? Many thanks!

My .emacs python part looks like

    (require 'python-mode)
    (setq-default py-shell-name "ipython")
    (setq-default py-which-bufname "IPython")
    ; 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)
calbear
  • 77
  • 3

1 Answers1

1

In order to split the window

(setq py-split-windows-on-execute-p t)

is needed, resp. reset to default - last line in example. Maybe check settings via M-x customize ... also, which may conflict with setq from init.

When selecting shell for execution: a shebang in buffer might override default py-shell-name. When shebang should be ignored, use

(setq py-force-py-shell-name-p t)

See menu

Python/Customize/Switches/Interpreter

for an easy way to change this value during current session.

Andreas Röhler
  • 4,804
  • 14
  • 18
  • Thank you very much, Andreas! (setq py-force-py-shell-name-p t) works! But when (setq py-split-windows-on-execute-p t), current code window keeps splitting until there are four windows, then I remember why I set it to nil... Anyway, I'll try tweaking more. One more question, is there a way to know which py-* variant does what besides reading python-mode.el? – calbear Oct 03 '14 at 05:30
  • @calbear You could check out the current trunk: bzr branch lp:python-mode. Bug lp:1361531 not solved yet - some improvement however should be feasible. – Andreas Röhler Oct 05 '14 at 15:21