I'm using emacs-w64 on Windows 7 (https://sourceforge.net/projects/emacsbinw64/). When I run
M-x run-python
I get the following error trace:
Debugger entered--Lisp error: (file-error "Searching for program" "no such file or directory" "c\\:/Users/Geoff\\") start-process("Python" #<buffer *Python*> "c\\:/Users/Geoff\\" "Ferrari/AppData/Local/Programs/Python/Python35-32/python.exe" "-i")
The problem can be traced to two things.
- My Windows username has a space in it.
- I've set my
shell-file-name to use zsh.exe from cygwin.
If I use zsh.exe as my shell-file-name then the following code produces this result:
(shell-quote-argument "c:/Users/Geoff Ferrari/AppData/Local/Programs/Python/Python35-32/python.exe")
"c\\:/Users/Geoff\\ Ferrari/AppData/Local/Programs/Python/Python35-32/python.exe -i"'
However, if I leave my shell-file-name as the default cmdproxy.exe supplied by emacs, then it produces this result:
"\"c:/Users/Geoff Ferrari/AppData/Local/Programs/Python/Python35-32/python.exe\""
As you can see, using zsh.exe as my shell-file-name produces different results. In particular, it adds \ before the space in my username.
These differences mean that python-shell-make-comint fails for me because split-string-and-unquote splits my python-shell-command on the space in my username. The result that you see in the error message above is that the command given to start-process is just the path up to the space in my username c:/Users/Geoff", which of course is not an existing command, while the rest of the path is passed as the first of the two arguments: "Ferrari/AppData/Local/Programs/Python/Python35-32/python.exe" "-i"
I don't know whether it's python.el that's at fault here, but I thought I'd make you aware of this first. It would be good to have a proper resolution to the issue. But for the moment I'm working around the problem like this:
Before changing shell-file-name I store its original value like so:
(defvar default-shell-file-name shell-file-name)
Then I use the following advice on python-shell-parse-command:
(defun python-shell-parse-command--adjust-shell-command (orig-fun &rest args)
(let ((shell-file-name default-shell-file-name))
(apply orig-fun args)))
(advice-add 'python-shell-parse-command :around #'python-shell-parse-command--adjust-shell-command)
I'm no expert here, but I guess that the problem is that start-process is going to use cmdproxy.exe even if I've set my shell-file-name to zsh.exe . So that command that is passed to start-process still needs to be quoted for Windows rather than for zsh.exe.
I'm using emacs-w64 on Windows 7 (https://sourceforge.net/projects/emacsbinw64/). When I run
M-x run-pythonI get the following error trace:
Debugger entered--Lisp error: (file-error "Searching for program" "no such file or directory" "c\\:/Users/Geoff\\") start-process("Python" #<buffer *Python*> "c\\:/Users/Geoff\\" "Ferrari/AppData/Local/Programs/Python/Python35-32/python.exe" "-i")The problem can be traced to two things.
shell-file-nameto use zsh.exe from cygwin.If I use zsh.exe as my
shell-file-namethen the following code produces this result:(shell-quote-argument "c:/Users/Geoff Ferrari/AppData/Local/Programs/Python/Python35-32/python.exe")"c\\:/Users/Geoff\\ Ferrari/AppData/Local/Programs/Python/Python35-32/python.exe -i"'However, if I leave my
shell-file-nameas the default cmdproxy.exe supplied by emacs, then it produces this result:"\"c:/Users/Geoff Ferrari/AppData/Local/Programs/Python/Python35-32/python.exe\""As you can see, using zsh.exe as my
shell-file-nameproduces different results. In particular, it adds \ before the space in my username.These differences mean that python-shell-make-comint fails for me because split-string-and-unquote splits my python-shell-command on the space in my username. The result that you see in the error message above is that the command given to start-process is just the path up to the space in my username c:/Users/Geoff", which of course is not an existing command, while the rest of the path is passed as the first of the two arguments: "Ferrari/AppData/Local/Programs/Python/Python35-32/python.exe" "-i"
I don't know whether it's python.el that's at fault here, but I thought I'd make you aware of this first. It would be good to have a proper resolution to the issue. But for the moment I'm working around the problem like this:
Before changing
shell-file-nameI store its original value like so:(defvar default-shell-file-name shell-file-name)Then I use the following advice on python-shell-parse-command:
I'm no expert here, but I guess that the problem is that start-process is going to use cmdproxy.exe even if I've set my
shell-file-nameto zsh.exe . So that command that is passed to start-process still needs to be quoted for Windows rather than for zsh.exe.