What combination of python-mode, ipython, (ipython.el) versions/releases and init.el/.emacs.d code work?

emacs, emacs24, ipython, python, python-mode

Solution

With Emacs24, I use the default python.el (not python-mode.el), which started on github.

when I start ipython with `python-shell-switch-to-shell` or `C-c C-p` (Python menu -> start interpreter), I get ipython. Tab completion works.

ipython is the default python interpreter (see my init file)

when I have started a ipython shell I can send a file or the selected region to it (commands available in the menu), and it gets evaluated correctly.

As a side note, you can start the jedi autocompletion with `jedi:setup` when you are in a python shell. It gives nice popups with parameters help and doc, and you can choose to fire it at the dot (instead of after 3 characters). See IPython auto-completion emacs24 doesn't work . It can be seen as a complement rather than a replacement to ipython.

Following my config:

;; trying ipython tab completion: that works :)
(setq
 python-shell-interpreter "ipython"
 python-shell-interpreter-args ""
 python-shell-prompt-regexp "In \\[[0-9]+\\]: "
 python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
 python-shell-completion-setup-code "from IPython.core.completerlib import module_completion"
  python-shell-completion-module-string-code "';'.join(module_completion('''%s'''))\n"
  python-shell-completion-string-code "';'.join(get_ipython().Completer.all_completions('''%s'''))\n"
     )

taken from http://www.emacswiki.org/emacs/PythonProgrammingInEmacs#toc5

Hope this helps.

Problem

My goal is to use Emacs 24 as my python editor ( also has a Matlab and R editor but that's not what my question is about ). (Please let me know if I left out any information or if I did not state something clearly.) I've been able to set up my packages and my init.el file in such a way that I'm able to get tab completion, correct highlighting and snippets for python. I'm using python-mode.el as my python mode. The problems all revolve around this: I want to use ipython as my python shell, in order to use its tab completion functions when debugging scripts. - However, when I start ipython (using M-x ipython) I have no tab completion. Furthermore, it does not show "[1] in:", however it does show "[1] out:". - I would like to make ipython my default shell in Emacs. However, attempts at this have failed (e.g. setting C:\PATH\TO\IPython.exe onto py-python-command). - When I try to run my python script using C-c C-c it runs using the normal Python, and indeed stops at the position I tell the debugger to stop (I use ipdb.set_trace). however when I use another type of command that is supposed to start IPython (like setting the region to my entire script and running py-execute-region-ipython) IPython does not function. It does start an IPython shell, or at least it seems to, but I can just type in the shell like it was a text editor (fyi: in the mini buffer it shows "Comint:run shell-compile"). My question is: What combination of package versions and lisp code in my init.el file should allow me to use ipython with tab completion as my default shell in Emacs? I am willing to downgrade some of the packages if necessary. Extra info: From what I've read on the Project page of Python-mode.el I understand that there are still some bugs regarding IPython with the latest version of this package, so it's probably necessary to use an old version. I've been googling a lot to search for a solution, and I've not been able to find one that works for me. I'm running - python-mode 6.1.3, - ipython 1.1.0 - I tried ipython.el from https://raw.github.com/ipython/ipython/d2d967af9de6081c8cdbab0eab1115164e5e72bd/docs/emacs/ipython.el, But from contact with the developer of python-mode.el this seems to be deprecated, and no integrated into python-mode.el. - GNU Emacs 24.3.1 (i386-mingw-nt6.1.7601) of 2013-03-17 on MARVIN - Windows 7 64bit. My init.el looks like (python stuff is at the bottom): ` ``` ;; Requisites: Emacs >= 24 (require 'package) (package-initialize) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/")) (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t) (package-refresh-contents) (defun install-if-needed (package) (unless (package-installed-p package) (package-install package))) ;; make more packages available with the package installer --> ;; removed python mode since the version I got had errors (setq to-install '( ;python-mode magit yasnippet jedi auto-complete autopair find-file-in-repository flycheck)) (mapc 'install-if-needed to-install) ;;------------R STUFF----------- (add-to-list 'load-path "C:\\emacs-24.3\\site-lisp\\ess-13.09-1") (setq ess-use-auto-complete t) (load "ess-site") ;;------------MatLab STUFF----------- ; add folder of matlab-mode.el (add-to-list 'load-path "C:\\Users\\Rob Ter Horst\\AppData\\Roaming\\.emacs.d\\elpa\\matlab-mode-20130829.142") (load-library "matlab-load") (matlab-cedet-setup) (setq matlab-show-mlint-warnings t) (add-hook 'matlab-mode-hook 'auto-complete-mode) (add-hook 'matlab-mode-hook 'mlint-minor-mode) ;;------------GENERAL STUFF----------- ; Ido mode: Ido-powered versions of code. Most ido commands are named ido-xxxxx ; so find-file becomes ido-find-file, and so on. (setq ido-enable-flex-matching t) (setq ido-everywhere t) (ido-mode t) (global-linum-mode t) ;Use y or n always instead of yes/no (defalias 'yes-or-no-p 'y-or-n-p) ;; -------------------- extra nice things Andrea Crotti-------------------- ;; use shift to move around windows (windmove-default-keybindings 'shift) (show-paren-mode t) ; Turn beep off (setq visible-bell nil) (custom-set-variables '(ansi-color-names-vector ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"]) '(custom-enabled-themes (quote (wheatgrass)))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) (put 'downcase-region 'disabled nil) ;;------------PYTHON STUFF----------- ;(require 'magit) ;(global-set-key "\C-xg" 'magit-status) (require 'auto-complete) (require 'autopair) (require 'yasnippet) (require 'jedi) ;yasnipped settings (setq yas-snippet-dirs '("C:\\Users\\Rob Ter Horst\\AppData\\Roaming\\.emacs.d\\elpa\\yasnippet-20140106.1009\\snippets")) (add-to-list 'load-path "C:\\Users\\Rob Ter Horst\\AppData\\Roaming\\.emacs.d\\elpa\\yasnippet-20140106.1009") (global-set-key [f7] 'find-file-in-repository) ; auto-complete mode extra settings (setq ac-auto-start 2 ac-override-local-map nil ac-use-menu-map t ac-candidate-limit 20) ;; ;; Python mode settings (setq py-install-directory "C:\\Users\\Rob Ter Horst\\AppData\\Roaming\\.emacs.d\\self_installed\\python-mode.el-6.1.3") (add-to-list 'load-path py-install-directory) (add-to-list 'auto-mode-alist '("\\.py$" . python-mode)) (when (featurep 'python) (unload-feature 'python t)) (require 'python-mode) (setq py-electric-colon-active t) (add-hook 'python-mode-hook 'autopair-mode) (add-hook 'python-mode-hook 'yas-minor-mode) (add-hook 'python-mode-hook 'auto-complete-mode) ;; ;; Jedi settings ;; It's also required to run "pip install --user jedi" and "pip ;; install --user epc" to get the Python side of the library work ;; correctly. ;; With the same interpreter you're using. ;; if you need to change your python intepreter, if you want to change it ;; (setq jedi:server-command ;; '("python2" "/home/andrea/.emacs.d/elpa/jedi-0.1.2/jediepcserver.py")) (add-hook 'python-mode-hook (lambda () (jedi:setup) (jedi:ac-setup) (local-set-key "\C-cd" 'jedi:show-doc) (local-set-key (kbd "M-SPC") 'jedi:complete) (local-set-key (kbd "M-.") 'jedi:goto-definition))) ; ipython settings (setq py-python-command "C:\\Python27\\Scripts\\ipython.exe") (setq py-complete-function 'ipython-complete py-shell-complete-function 'ipython-complete py-shell-name "ipython" py-which-bufname "IPython") ;(require 'ipython) ;With tab autocompletion in ipdb I get an error that might be solved by changing this var ;the error: "variable binding depth exceeds max-specpdl-size" (setq max-specpdl-size 32000) ; Try to add flycheck --> flycheck causes emacs to become incredibly slow on big script with ; many style errors (as present in a lot of my older scripts, so I do not want to activate it ; by default ;(setq flycheck-highlighting-mode 'lines) ;(add-hook 'python-mode-hook 'global-flycheck-mode) ;(flycheck-select-checker 'python-flake8) ;(provide 'init-flycheck) (yas-reload-all) ``` `

Original source