I have had difficulties to run any python code when using python-execute-file (SPC m c c in spacemacs), until I finally found out that I have to use python-shell-send-buffer (SPC m s b in Spacemacs) to run code.

I wonder what is the purpose of python-execute-file then?

  • I don't think there is a python-execute-file function in python mode, but Spacemacs seems to have a function with a similar name: spacemacs/python-execute-file.
    – Omar
    Oct 7, 2017 at 1:52

1 Answer 1


FWIW, in vanilla emacs, I cannot find python-execute-file, but looks like it is similar to python-shell-send-file in stock emacs.

  • python-shell-send-file (bound by default to C-c C-l) prompts the user to select the file they want to send to the python-shell-interpreter (default value is "python").. it need not be the current file or one of the open Python files.
  • python-shell-send-buffer (bound by default to C-c C-c) sends the current buffer to the python-shell-interpreter without asking any questions.

So if you want to quickly want to evaluate the script you are currently working on, you would use python-shell-send-buffer. But if you want to evaluation some other file (already open or not), you would use python-shell-send-file (or may be python-execute-file).

  • I think it's something different. It sais: spacemacs/python-execute-file is an interactive Lisp function. [...] Execute a python script in a shell.
    – user430
    Jun 7, 2017 at 15:30
  • Is it possible to send only a highlighted region of a buffer?
    – fraxture
    Jan 2, 2019 at 17:08
  • @fraxture Yes, you can use python-shell-send-region which is bound to C-c C-r by default.
    – sinekonata
    Nov 9, 2020 at 23:01

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .