If the path to the python executable contains an embedded space, any
command that attempts to spawn a shell will fail with "invalid
argument" since the space makes the command appear to contain extra
In some sense, the root of the problem is locate-file, called by
executable-find (both defined in files.el). locate-file does not
return quoted paths. I'm not sure if the best fix is at the
locate-files level, since I'm not sure what consequences this might
have elsewhere, esp on non-Windows OS's. The most localized fix
would be in python.el, changing python-shell-parse-command to add
the required quotes. In the simplest case, this would be just change
the format statement from
(format "%s %s"
(format "\"%s\" %s"
This definitely works on Windows, but I'm not certain how this would
affect other OS's. Perhaps the format string has to be conditioned
on the OS.