GNU bug report logs - #21421
24.5; python mode interpreter path problem on windows.

Previous Next

Package: emacs;

Reported by: Currell Berry <currellberry <at> gmail.com>

Date: Sat, 5 Sep 2015 00:53:02 UTC

Severity: normal

Tags: notabug

Merged with 20237

Found in version 24.5

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21421 in the body.
You can then email your comments to 21421 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#21421; Package emacs. (Sat, 05 Sep 2015 00:53:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Currell Berry <currellberry <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 05 Sep 2015 00:53:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Currell Berry" <currellberry <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; python mode interpreter path problem on windows.
Date: Sat, 05 Sep 2015 00:48:51 +0000
Hello,

python-shell-parse-command in python.el appears to have an issue on 
Windows
which prevents proper startup of the python interpreter depending on the
interpreter's path.  Here is the current version of 
python-shell-parse-command in python.el, as of Emacs 24.5.1.

 (defun python-shell-parse-command ()    ;FIXME: why name it "parse"?
   "Calculate the string used to execute the inferior Python process."
   ;; FIXME: process-environment doesn't seem to be used anywhere within
   ;; this let.
   (let ((process-environment 
(python-shell-calculate-process-environment))
         (exec-path (python-shell-calculate-exec-path)))
     (format "%s %s"
             ;; FIXME: Why executable-find?
             (shell-quote-argument
              (executable-find python-shell-interpreter))
             python-shell-interpreter-args)))

The problem is with the usage of "shell-quote-argument" to quote the 
pathname coming out of "executable-find".

Suppose you have python installed at "C:\Anaconda\python.exe", and 
"C:\Anaconda" is on your path.

Then when we run
         (executable-find python-shell-interpreter)
we get the output
        "c:/Anaconda/python.exe"
This is a valid path which can be used to launch python.

However
        (shell-quote-argument "c:/Anaconda/python.exe")
results in
        "c\\:/Anaconda/python.exe"
This is NOT a valid windows path, as an extra backquote has been
inserted before the colon (second character).

Since python-parse-interpeter uses shell-quote-argument, you get the 
following error when you run "run-python" to start up a python 
interpreter.

"apply: Searching for program: no such file or directory, 
c\:/Anaconda/python.exe"

If I modify Python.el to remove the call to "shell-quote-argument",
run-python works properly on my system.

Here is the value of my PATH in emacs.
(getenv "PATH")
":/usr/local/bin:/mingw/bin:/bin;C:\\Program 
Files\\ImageMagick-6.9.2-Q16;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program 
Files (x86)\\Git\\cmd;C:\\Anaconda;C:\\Program Files 
(x86)\\emacs\\bin;C:\\MinGW\\bin;C:\\MinGW\\msys\\1.0;C:\\Program 
Files\\gs\\gs9.09\\lib;C:\\Program Files\\gs\\gs9.09\\bin;C:\\Program 
Files (x86)\\Calibre2\\;C:\\Program Files 
(x86)\\Graphviz2.38\\bin;C:\\Program Files (x86)\\MiKTeX 
2.9\\miktex\\bin;C:\\Users\\vancan1ty\\AppData\\Roaming\\cabal\\bin;C:\\Users\\vancan1ty\\AppData\\Roaming\\npm;C:\\Python27\\Scripts;C:\\Program 
Files (x86)\\Nmap;C:\\Program Files\\Boot2Docker for 
Windows;C:\\altera\\13.0sp1\\modelsim_ase\\win32aloem;C:\\Users\\vancan1ty\\AppData\\Local\\Pandoc\\"

In GNU Emacs 24.5.1 (i686-pc-mingw32)
 of 2015-04-11 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/usr --host=i686-pc-mingw32'

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Python

Minor modes in effect:
  shell-dirtrack-mode: t
  evil-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  evil-local-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
C-; is undefined
Quit [2 times]
Making completion list... [4 times]
Saving file c:/Program Files 
(x86)/emacs/share/emacs/24.5/lisp/progmodes/python.el...
Wrote c:/Program Files 
(x86)/emacs/share/emacs/24.5/lisp/progmodes/python.el
byte-code: Beginning of buffer [2 times]
Can't guess python-indent-offset, using defaults: 4
apply: Searching for program: no such file or directory, 
c\:/Anaconda/python.exe
progn: End of line [2 times]
user-error: Please specify a file name for the buffer [2 times]
byte-code: End of buffer [12 times]

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mail-utils python cua-base eieio-opt
speedbar sb-image ezimage dframe compile warnings skeleton derived pcase
rx loadhist ace-window avy vc-git json help-mode shell misearch
multi-isearch ob-dot org org-macro org-footnote org-pcomplete pcomplete
org-list org-faces org-entities noutline outline easy-mmode org-version
ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys
ob-comint comint ansi-color ob-core ob-eval org-compat org-macs
org-loaddefs format-spec find-func cal-menu calendar cal-loaddefs
cl-macs gv server evil evil-integration undo-tree diff evil-maps
evil-commands ffap url-parse auth-source eieio byte-opt bytecomp
byte-compile cl-extra cconv eieio-core gnus-util mm-util mail-prsvr
password-cache url-vars evil-command-window evil-types evil-search
evil-ex evil-macros evil-repeat evil-states evil-core advice help-fns
evil-common windmove thingatpt rect evil-digraphs evil-vars ring edmacro
kmacro cl-loaddefs cl-lib info easymenu package epg-config time-date
tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
dos-w32 ls-lisp w32-common-fns disp-table w32-win w32-vars tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
w32notify w32 multi-tty emacs)

Memory information:
((conses 8 284198 39511)
 (symbols 32 33119 0)
 (miscs 32 160 697)
 (strings 16 64392 15870)
 (string-bytes 1 1826027)
 (vectors 8 33104)
 (vector-slots 4 1301156 19920)
 (floats 8 112 474)
 (intervals 28 2003 81)
 (buffers 508 19))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21421; Package emacs. (Sat, 05 Sep 2015 07:13:01 GMT) Full text and rfc822 format available.

Message #8 received at 21421 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Currell Berry <currellberry <at> gmail.com>
Cc: 21421 <at> debbugs.gnu.org
Subject: Re: bug#21421: 24.5; python mode interpreter path problem on windows.
Date: Sat, 05 Sep 2015 10:12:19 +0300
> From: "Currell Berry" <currellberry <at> gmail.com>
> Date: Sat, 05 Sep 2015 00:48:51 +0000
> 
> python-shell-parse-command in python.el appears to have an issue on
> Windows which prevents proper startup of the python interpreter
> depending on the interpreter's path.  Here is the current version of
> python-shell-parse-command in python.el, as of Emacs 24.5.1.
> 
>   (defun python-shell-parse-command ()    ;FIXME: why name it "parse"?
>     "Calculate the string used to execute the inferior Python process."
>     ;; FIXME: process-environment doesn't seem to be used anywhere within
>     ;; this let.
>     (let ((process-environment 
> (python-shell-calculate-process-environment))
>           (exec-path (python-shell-calculate-exec-path)))
>       (format "%s %s"
>               ;; FIXME: Why executable-find?
>               (shell-quote-argument
>                (executable-find python-shell-interpreter))
>               python-shell-interpreter-args)))
> 
> The problem is with the usage of "shell-quote-argument" to quote the 
> pathname coming out of "executable-find".
> 
> Suppose you have python installed at "C:\Anaconda\python.exe", and 
> "C:\Anaconda" is on your path.
> 
> Then when we run
>           (executable-find python-shell-interpreter)
> we get the output
>          "c:/Anaconda/python.exe"
> This is a valid path which can be used to launch python.
> 
> However
>          (shell-quote-argument "c:/Anaconda/python.exe")
> results in
>          "c\\:/Anaconda/python.exe"
> This is NOT a valid windows path, as an extra backquote has been
> inserted before the colon (second character).

My crystal ball says you have w32-shell-name set to Cygwin's Bash, in
which case this is bug#20237, whose root cause is incompatibility
between Cygwin file names and native Windows file names.  See
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20237#50 for more
details.

In a nutshell, setting w32-shell-name to point to Bash causes
shell-quote-argument to work differently, under the assumption that
file names are in Posix-style /foo/bar format, whereas your Python
file name is in native Windows format.




Merged 20237 21421. Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 05 Sep 2015 07:13:02 GMT) Full text and rfc822 format available.

Added tag(s) notabug. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Thu, 02 Jun 2016 02:55:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 20237 <at> debbugs.gnu.org and Da Zhang <zhangda82 <at> gmail.com> Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Sun, 05 Jun 2016 03:21:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 03 Jul 2016 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 354 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.