0

I am trying to set my Elpy on my home machine and, so far, everything works except actually running the Python interpreter. I normally launch the interpreter and run code via C-c C-c, but when I do that under the current install I get the following backtrace:

Debugger entered--Lisp error: (file-error "Searching for program" "No such  file or directory" "\\~/anaconda3/bin/python")
  make-process(:name "Python" :buffer #<buffer *Python*> :command ("\\~/anaconda3/bin/python" "-i"))
  apply(make-process (:name "Python" :buffer #<buffer *Python*> :command ("\\~/anaconda3/bin/python" "-i")))
  start-process("Python" #<buffer *Python*> "\\~/anaconda3/bin/python" "-i")
  apply(start-process "Python" #<buffer *Python*> "\\~/anaconda3/bin/python" "-i")
  start-file-process("Python" #<buffer *Python*> "\\~/anaconda3/bin/python" "-i")
  apply(start-file-process "Python" #<buffer *Python*> "\\~/anaconda3/bin/python" "-i")
  comint-exec-1("Python" #<buffer *Python*> "\\~/anaconda3/bin/python" ("-i"))
  comint-exec(#<buffer *Python*> "Python" "\\~/anaconda3/bin/python" nil ("-i"))
  make-comint-in-buffer("Python" "*Python*" "\\~/anaconda3/bin/python" nil "-i")
  apply(make-comint-in-buffer "Python" "*Python*" "\\~/anaconda3/bin/python" nil "-i")
  python-shell-make-comint("\\~/anaconda3/bin/python -i" "Python" t)
  run-python("\\~/anaconda3/bin/python -i" nil t)
  elpy-shell-get-or-create-process()
  elpy-shell--ensure-shell-running()
  elpy-shell-send-region-or-buffer-and-step(nil)
  funcall-interactively(elpy-shell-send-region-or-buffer-and-step nil)
  call-interactively(elpy-shell-send-region-or-buffer-and-step)
  elpy-shell--send-with-step-go(elpy-shell-send-region-or-buffer-and-step nil nil nil)
  elpy-shell-send-region-or-buffer(nil)
  funcall-interactively(elpy-shell-send-region-or-buffer nil)
  call-interactively(elpy-shell-send-region-or-buffer nil nil)
  command-execute(elpy-shell-send-region-or-buffer)

Obviously it is not finding my Python install under \\~/anaconda3/bin/python, most likely due to the prepended \\ in my path (right?). I ensured my paths are correct in my .emacs file and with elpy-config. Does anyone have ideas on why this is happening?

  • 1
    Do you see the same thing when starting Emacs using emacs -Q (no init file)? If not, bisect your init file to find the culprit. – Drew Mar 9 at 17:52
  • 1
    My guess is that python-shell-interpreter is wrongly set to "\\~/anaconda3/bin/python". Don't rely on elpy-config but customize it yourself to "~/anaconda3/bin/python". – Tobias Mar 9 at 22:25
  • 1
    I think that it might be actually trying to prevent tilde from being interpreted by the shell as your home directory. Just set it to the absolute path (if you need this to change based on the user running Emacs, then add the code to set it up in init.el? – wvxvw Mar 10 at 12:09
  • @Drew Finally zeroed in on the problem. I have '(python-shell-interpreter "~/anaconda3/bin/python") within custom-set-variables. After commenting that out it runs fine (well, more or less fine...now the whole script gets printed to the interpreter when run, but that's something else to figure out). Thanks for the tip. – tnknepp Mar 10 at 12:14
  • @Tobias I thought that too, but I had my paths specified within .emacs as well. – tnknepp Mar 10 at 12:15
0

Here was the problem: I had "'(python-shell-interpreter "~/anaconda3/bin/python")" within custom-set-variables in .emacs. At some point the tilde was being escaped (as wvxvw said, tilde has no special meaning in Windows environments). So I replaced the tilde with hard-coded path and all is well again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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