0

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.

asked Jul 7, 2015 at 9:24

3 Answers 3

1

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.

answered Jul 7, 2015 at 16:13
Sign up to request clarification or add additional context in comments.

3 Comments

thank you for the response. I replaced (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.
@usr8 Hmm, check if py-ipython-command points to executable, resp. customize that. Where and which way is IPython installed?
I installed Anaconda and it sits in C:/Python27
0

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
 ))
answered Jul 7, 2015 at 10:32

2 Comments

py-which-bufname is internally used, setting it might have undefined results. Requiring ipython might cause errors - stuff in ipython.el dates from times, where no support for IPython was provided.
@AndreasRöhler, it work fine for me. But I will keep it in mind for next update.
0

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!

answered Jul 7, 2015 at 10:26

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.