I am new to lisp and having hard time configuring emacs for ipython. Part of my .emacs file looks like this:
;; Python mode settings
(require 'python-mode)
(add-to-list 'load-path "~/.emacs.d/elpa/")
(let ((default-directory "~/.emacs.d/elpa/"))
(normal-top-level-add-to-load-path '("."))
(normal-top-level-add-subdirs-to-load-path))
(autoload 'python-mode "python-mode" "Python Mode." t)
(add-to-list 'auto-mode-alist '("\\.py$\\'" . python-mode))
(add-to-list 'interpreter-mode-alist '("python" . python-mode))
(require 'ipython)
I run emacs --debug -init from command line window and get the following error message when emacs is launched:
Debugger entered--Lisp error: (wrong-type-argument listp "-i")
nconc("-i" ("-colors" "LightBG"))
eval-buffer(#<buffer *load*-610080> nil "c:/Users/xxxx/AppData/Roaming/.emacs.d/elpa/python-mode-20150616.2346/ipython.el" nil t) ; Reading at buffer position 9523
load-with-code-conversion("c:/Users/xxxx/AppData/Roaming/.emacs.d/elpa/python-mode-20150616.2346/ipython.el" "c:/Users/xxxx/AppData/Roaming/.emacs.d/elpa/python-mode-20150616.2346/ipython.el" nil t)
require(ipython)
This might be something that should be very obvious, but not sure how to fix this to be honest. It'd be very helpful if you can point me in the right direction. Thanks.
3 Answers 3
Seems you are using python-mode from python-mode.el: No special setting for IPython should be neccessary. Don't require ipython.el, it's outdated.
Configuring py-shell-name to "ipython" will make it the default shell.
M-x ipython RET should work right out of the box, also sending stuff to ipython-commands.
For special cases overriding defaults have a look into README.org.
3 Comments
(require 'ipython) with (setq py-shell-name "ipython"). But, i get the following message when running <kbd>M-x</kbd> ipython <kbd>RET</kbd>: failed to create process. What else could be wrong? Again, thanks for your help.Try change ipython command line as below:
(add-hook 'python-mode-hook
(lambda ()
;You can uncomment next lines
;(set (make-variable-buffer-local 'beginning-of-defun-function)
; 'py-beginning-of-def-or-class)
;(setq outline-regexp "def\\|class ")
;(setq tab-width 4)
;(define-key py-mode-map "\C-c4" 'uncomment-region )
;(outline-minor-mode 1)
;(linum-mode 1)
;Ipython settings sections
(require 'ipython)
(setq-default py-shell-name "ipython")
(setq-default py-which-bufname "IPython")
(setq py-python-command-args '("--colors=linux")) ;Command line for run iPython
))
2 Comments
I have the following in my init.el to make ipython the default python interpreter:
(setq
python-shell-interpreter "ipython"
python-shell-interpreter-args "-i --simple-prompt"
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")
To start the interpreter, all you need to do then is call run-python.
Hope this helps!