1

When I try to do C-c C-c to run my buffer (python.el), I get the error: Wrong type argument: arrayp, nil. This is what the backtrace looks like:

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)                                                                                                                       
  replace-regexp-in-string("[^-0-9a-zA-Z_./\n]" "\\\\\\&" nil)                                                                                                                       
  shell-quote-argument(nil)                                                                                                                                                          
  python-shell-parse-command()                                                                                                                                                       
  byte-code("^H\203^S^@\301\302\303 \"\304\305!\306^H!\307UE\207\303 \310\311E\207" [current-prefix-arg read-string "Run Python: " python-shell-parse-command y-or-n-p "Make dedicat$
  call-interactively(run-python)                                                                                                                                                     
  python-shell-get-or-create-process()                                                                                                                                               
  python-shell-send-region(1 598 nil)                                                                                                                                                
  python-shell-send-buffer(nil)                                                                                                                                                      
  call-interactively(python-shell-send-buffer nil nil)                                                                                                                               
  command-execute(python-shell-send-buffer)

Anyone know what's going on? I'm fairly new to emacs, but C-c C-c has never worked for me because of this error.

dieggsy
  • 475
  • 2
  • 10

2 Answers2

1

The problem seems to lie with python-shell-parse-command. It is passing nil to shell-quote-argument, and that function expects a string argument, not nil. (Actually, it passes nil on to replace-regexp-in-string, who complains. But I'm betting that shell-quote-argument needs a string arg.

Consider reporting this as a bug to the maintainer of python-shell-parse-command, aka of python-shell-send-buffer.

BTW, you will get a more complete backtrace if you load the source file instead of the byte-compiled file, for the code that defines run-python.

Drew
  • 75,699
  • 9
  • 109
  • 225
0

It looks like your python-shell-interpreter variable is not set properly.

You can examine this variable with C-h C-v python-shell-interpreter. It should be a string containing the path to your Python interpreter. (On Linux & Mac OS you can check where your interpreter is with which python on your command line).

You can set it with (setq python-shell-interpreter <path to your Python interpreter>). A quick, permanent fix would be to set it in your init.el file.

Nat Knight
  • 101
  • 1