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.

usr8
  • 11
  • 2

3 Answers3

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.

Andreas Röhler
  • 4,804
  • 14
  • 18
  • thank you for the response. I replaced `(require 'ipython)` with `(setq py-shell-name "ipython")`. But, i get the following message when running M-x `ipython` RET: `failed to create process`. What else could be wrong? Again, thanks for your help. – usr8 Jul 08 '15 at 04:03
  • @usr8 Hmm, check if py-ipython-command points to executable, resp. customize that. Where and which way is IPython installed? – Andreas Röhler Jul 08 '15 at 05:16
  • I installed Anaconda and it sits in C:/Python27 – usr8 Jul 08 '15 at 05:50
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 ""
 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!

Andrew Winterbotham
  • 1,000
  • 7
  • 13
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
              ))
Michael Kazarian
  • 4,376
  • 1
  • 21
  • 25
  • 1
    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. – Andreas Röhler Jul 07 '15 at 16:37
  • @AndreasRöhler, it work fine for me. But I will keep it in mind for next update. – Michael Kazarian Jul 08 '15 at 05:13