1

I would like the Python inferior process to start (if it is not already running) whenever I create a python-mode buffer (for example, by visiting a .py file).

Some functions in anaconda-mode etc. depend on an inferior Python process running. Also, I want to be able to C-c C-c and see the output.

Everything works fine if I create the python-mode buffer, then manually run M-x run-python.

However, if I run (add-hook 'python-mode-hook 'run-python), then create a python-mode buffer, I get no inferior Python process but this error:

Wrong number of arguments: (1 . 3), 0

I don't know if it's relevant, but I have this in my custom.el:

(defvar python-shell-interpreter "ipython")
(defvar python-shell-interpreter-args "-i")

I had thought that this question would help but it doesn't.

Please could you advise how to create an inferior Python process if it is not already running? Thanks in advance.

Versions:

  • Emacs 24.5.1 (i686-pc-mingw32)
  • prelude latest at time of writing
  • Python 3.5.1 (Anaconda 2.5.0 64-bit)
  • Windows 10
0

1 Answer 1

3

Check the arguments that run-python requires, and supply them in your hook function that calls it (use a lambda with interactive or a named command that you defined). Otherwise, if you want to interact with it then use call-interactively in the mode-hook function.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.