Reputation: 313
I tried to launch ipython console on emacs by typing C-c C-p while editing a python script. But the ipython console looks blank. Although when I type some command there is an output and the Out prompt is displayed. Furthermore when I exit(), many In() prompt are displayed. Why is this the case?
I am using emacs versiion 24.3, ipython 2.1.0 and python 2.7.6. Following is my init.el
;;; To start emacs maximized at startup
(w32-send-sys-command 61488)
;;; To remove the toolbar from emacs
(tool-bar-mode 0)
;;; IDO configuration
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)
;;; Add MELPA repository
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
;;; Configure Aspell
(add-to-list 'exec-path "C:/Program Files (x86)/Aspell/bin/")
; Tell emacs to use Aspell and provide the location of custom dictionary
(setq ispell-program-name "aspell")
(setq ispell-personal-dictionary "C:/emacs/.emacs.d/my_dict/my_dict.ispell")
; Turn it on
(require 'ispell)
;;; Flyspell configuration
(add-to-list 'load-path "~/.emacs.d/flyspell")
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
(autoload 'flyspell-delay-command "flyspell" "Delay on command." t)
(autoload 'tex-mode-flyspell-verify "flyspell" "" t)
(add-hook 'LaTeX-mode-hook 'flyspell-mode) ; Auto-start flyspell with LaTeX
;;; Enable auto-complete mode
(require 'auto-complete)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(require 'auto-complete-config)
(ac-config-default)
(global-auto-revert-mode t)
;;; RefTex configuration
(require 'reftex)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(add-hook 'latex-mode-hook 'turn-on-reftex)
;;; Activate code folding in AUCTeX
(add-hook 'LaTeX-mode-hook (lambda ()
(TeX-fold-mode 1)))
;;; Setup jedi
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)
;;; Pair braces and quotes automatically (autopair)
(require 'autopair)
(autopair-global-mode) ;; Enable autopair in all buffers
;; (setq py-install-directory "~/.emacs.d/python-mode.el-6.1.3")
;; (add-to-list 'load-path py-install-directory)
;; (require 'python-mode)
(require 'python)
(setq python-shell-interpreter "ipython")
(setq python-shell-interpreter-args "--pylab")
Upvotes: 2
Views: 732
Reputation: 42613
I had this same problem with Emacs 24.3.1 on Windows, and all my woes were finally fixed by shoehorning the ipython process into a subprocess (I tried everything I could from the "commentary" section to no avail - maybe Shaun knows exactly what he changed that fixed it?). You get an extra python process in the mix but I haven't had any issues with control between a code buffer and the python buffer. From my .emacs:
(setq
python-shell-interpreter "C:\Python27\\python.exe"
python-shell-interpreter-args "-u -c \"import subprocess; subprocess.call('ipython')\""
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")
Upvotes: 2
Reputation: 28531
I'm not familair enough with the python.el code to give you a good answer, but if you look at the beginning of python.el (the "Commentary:" section), you'll see it talks a bit about how to use Ipython. This said, there has been various problems with it. The python.el code in the upcoming 24.4 has significantly improved the Ipython support, so it doesn't require all that configuration and actually works (supposedly). Since 24.4 is very close to a release, we're looking for people who can help us get rid of the final few bugs, so it would be great if you could try the latest pretest (24.3.94) to see if that solves your problem, and if not, do a M-x report-emacs-bug
so we can fix it before the release.
Upvotes: 2