jorgenschaefer / pyvenv

Python virtual environment interface for Emacs
364 stars 57 forks source link

pyvenv workon ignoring conda env paths #79

Open frodera opened 6 years ago

frodera commented 6 years ago

Env:

Spacemacs ignores the Python version set via pyvenv (SPC-m-V-w, pyvenv-workon) and just uses system's default.

In my case my venv is a Conda environment:

> /Users/frodera/miniconda3/envs/python37/bin/python --version                                                                                                         
Python 3.7.0

After setting the env via SPC-m-V-w, emacs reports that the path of that env is the first one listed in Spacemacs' PATH and it even reports the name of the apparently loaded env (python37) in the status bar. However, when running a python script via SPC-m-c-c it reverts to system's default (2.7.15). See image attached.

getenv "PATH" -> /Users/frodera/miniconda3/envs/python37/bin:/usr/local/opt/coreutils/...

In order to get access the conda environments I have added this to my .spacemacs:

(defun dotspacemacs/user-config ()
  (use-package pyvenv
    :ensure t
    :init
    (setenv "WORKON_HOME" "/Users/frodera/miniconda3/envs")
    (pyvenv-mode 1))
  )

screen shot 2018-08-05 at 11 05 18

frodera commented 6 years ago

Not sure if related but I have noticed this error message in the messages buffer, when invoking python execution of the test.py file:

evil-line-move: End of buffer [9 times]
save-current-buffer: Symbol’s value as variable is void: python-shell--interpreter
Inferior Python finished
compilation ok.

python-shell--interpreter? Seems like that variable has an extra dash in it, and I cannot find it set anywhere in my Spacemacs installation, only references to similar variables are to python-shell-interpreter

frodera commented 6 years ago

Interestingly, if I do a python-shell-send-buffer it does open an ipython shell in the conda env running python 3.7.0, as expected:

In [6]: * Python version:       3.7.0 (default, Jun 29 2018, 20:13:13) 
[Clang 9.1.0 (clang-902.0.39.2)]
* Executable:       /Users/frodera/miniconda3/envs/python37/bin/python

Also, this does not trigger any Symbol’s value as variable is void: python-shell--interpreter messages.

yssource commented 5 years ago

The same problem happens to me also. SPC-m-c-c always calls the python by pyenv global version, instead of the pyvenv-activate version. This only happens to SPC-m-c-c. But I think may be it is caused by spacemacs, instead of pyvenv.