pyvenv icon indicating copy to clipboard operation
pyvenv copied to clipboard

workon not finding python executable

Open ltrojan opened this issue 6 years ago • 7 comments

Not quite sure how to explain this... pyvenv seem to search for python without finding it (??) here's a couple of things I've tried:

  • M-x pyvenv-workon RET boto RET produces the following on the Messages buffer: apply: Searching for program: No such file or directory, python
  • sending/running commands results in elpy-shell-get-or-create-process: Interpreter binaries not found in the current virtual environnement
  • the command run-python does however run the correct python interpreter
Python 3.6.5 (default, Apr  1 2018, 05:46:30)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> python.el: native completion setup loaded
>>> import sys
>>> sys.executable
'/home/user/.virtualenvs/boto/bin/python'
>>> 

I know this is a very sparse bit of info... please do let me know of more info I can provide!

ltrojan avatar May 22 '18 08:05 ltrojan

same error seems to happen when creating an env with virtualenv (not virtualenvwrapper) and use pyvenv-activate

ltrojan avatar May 22 '18 09:05 ltrojan

Hello, and thanks for the report! What's the output of M-x elpy-config? Could you also do M-x toggle-debug-on-error and do pyvenv-activate? That should produce a backtrace with more information.

jorgenschaefer avatar May 25 '18 09:05 jorgenschaefer

M-x elpy-config produces the same error (start emacs, open a new tmp.py file, M-x elpy-mode and finally M-x elpy-config)

as for the debug info:

Debugger entered--Lisp error: (file-error "Searching for program" "No such file or directory" "python")
  call-process("python" nil t nil "-m" "virtualenvwrapper.hook_loader" "--script" "/tmp/pyvenv-virtualenvwrapper-2169om8" "pre_activate" "/home/user/.virtualenvs/a3dsurf/")
  apply(call-process "python" nil t nil "-m" "virtualenvwrapper.hook_loader" "--script" "/tmp/pyvenv-virtualenvwrapper-2169om8" ("pre_activate" "/home/user/.virtualenvs/a3dsurf/")
  pyvenv-run-virtualenvwrapper-hook("pre_activate" "/home/user/.virtualenvs/a3dsurf/")
  pyvenv-activate("/home/user/.virtualenvs/a3dsurf")
  pyvenv-workon("a3dsurf")
  funcall-interactively(pyvenv-workon "a3dsurf")
  call-interactively(pyvenv-workon record nil)
  command-execute(pyvenv-workon record)
  execute-extended-command(nil "pyvenv-workon" "pyvenv-wo")
  funcall-interactively(execute-extended-command nil "pyvenv-workon" "pyvenv-wo")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

I hope this helps!

by the way,

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04 LTS
Release:        18.04
Codename:       bionic

ltrojan avatar Jun 03 '18 10:06 ltrojan

by the way, outside of my virtualenv there's no python executable in the path (it's only python3)

$ python

Command 'python' not found, but can be installed with:

sudo apt install python3       
sudo apt install python        
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.

$ which python3
/usr/bin/python3

turns out, if I create a python link to the python3 interpreter, things work out fine (workon and elpy-config both seem to work fine)......

hope this helps!

ltrojan avatar Jun 03 '18 11:06 ltrojan

Does (setq pyvenv-virtualenvwrapper-python "python3") fix the problem for you?

jorgenschaefer avatar Jun 09 '18 18:06 jorgenschaefer

Works for me.

divansantana avatar Oct 26 '19 22:10 divansantana

So this is not really a bug, in the customize buffer it clearly says, that the "educated guess" python can be off...

Knusper avatar Mar 19 '24 08:03 Knusper