I have always used emacs with python. I generally run my code on the ipython interpreter using C-c C-c
.
This is my ~/.emacs.d/init.el
in ubuntu where everything works fine.
(setq python-shell-interpreter "ipython"
python-shell-interpreter-args "--simple-prompt -i")
(custom-set-variables
;; custom-set-variables 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.
'(ansi-color-names-vector ["#212526" "#ff4b4b" "#b4fa70" "#fce94f" "#729fcf" "#ad7fa8" "#8cc4ff" "#eeeeec"])
'(custom-enabled-themes (quote (wombat)))
'(inhibit-startup-screen t))
(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 'erase-buffer 'disabled nil)
(add-hook 'python-mode-hook
(lambda ()
(setq indent-tabs-mode t)
(setq tab-width 4)
(setq python-indent 4)))
On the other hand on my mac I receive the following message when I try to run python interactively with C-c C-c
Start a Python process first with ‘M-x run-python’ or ‘C-c C-p’.
How can I get the same behaviour that I have on ubuntu ? Is this due to the emacs version?
EDIT Additional information:
This is the description of the C-c C-c
command on ubuntu.
C-c C-c runs the command python-shell-send-buffer, which is an
interactive compiled Lisp function.
It is bound to C-c C-c, <menu-bar> <Python> <Eval buffer>.
(python-shell-send-buffer &optional ARG)
Send the entire buffer to inferior Python process.
With prefix ARG allow execution of code inside blocks delimited
by "if __name__== '__main__':"