Open yorodm opened 4 years ago
Sorry, I forgot to add that I have elpy-rpc-virtualenv-path
set to 'current
in my .custom.el
Great.
You can close if this not relevant anyomore :)
Care to explain why? I believe that having elpy-rpc-virtualenv-path
set to 'current
should make elpy-config
list my virtualenv as something other than c:/
also it should detect a proper interpreter (currently is detecting the python launcher)
I think @azzamsa assumed you found a solution to your problem because your post began with Sorry, I forgot ...
:) (I did the same...).
elpy-rpc-virtualenv-path
is used to specify which virtualenv to use for the RPC process (which is the process running in the background and providing code completion, static analysis and other functionnalities).
From what I saw in your elpy-config
result, the RPC seems to work fine, so elpy-rpc-virtualenv-path
should not be relevant in this case.
The problem you have seems to be more linked to virtualenv and its activation (as you said in your first post). Can I ask what is the path of the virtualenv you are trying to activate ?
If it is c:/WINDOWS/py.exe
, then everything seems fine (Elpy assumes the virtualenv name is the parent directory of the parent directory of the executable, so c:\
in your case).
So besides that, Is Elpy working as expected ?
Sorry again, I'm not a native English speaker and sometimes my thoughts get a little lost in translation.
My virtualenvs are located in other drive and I have WORKON_HOME
set so pyvenv
works like a charm. On the side of elpy
completion works fine too (BTW, thanks for your great work guys). The thing is even after calling pyvenv-activate
elpy still shows c:/windows
as the active virtualenv. I've tried setting elpy-rpc-virtualenv-path
to 'default
and still get the same results.
It may just be a display bug in elpy-config
.
Is your virtualenv properly activated when you run a python script ?
Elpy looks at the environment variable VIRTUAL_ENV
to detect an active virtualenv.
Could you check the result of M-x getenv VIRTUAL_ENV
?
Can I ask you as well what is the path of the virtualenv you are trying to activate ?
I don't know if this helps but calling elpy-config
is triggering pyvenv-post-activate-hook
even if I've previously activated a virtualenv with pyvenv-activate
. Maybe this is expected behavior but this removes my active virtualenv
every time.
elpy-config
is indeed supposed to deactivate your virtualenv temporarily (deactivate it, run some code, and re-activate it).
Maybe there is something wrong dring the re-activation.
Is your virtualenv deactivated when running this: (with-elpy-rpc-virtualenv-activated (message "rpc-python: %s" (executable-find elpy-rpc-python-command)))
?
Yes it does, it also detects c:/windows/py.exe
as the elpy-rpc-python-command
even if I set elpy-rpc-virtualenv-path
to 'default
.
Could you run the following snippet and post the result (deleting the sensitive data if necessary) so I can have an overview of you configuration:
(progn
(message "python env: %s" pyvenv-virtual-env)
(message "python env (env var): %s" (getenv "VIRTUAL_ENV"))
(message "python exec: %s" python-shell-interpreter)
(message "python exec (full): %s" (executable-find python-shell-interpreter))
(message "python rpc exec: %s" elpy-rpc-python-command)
(message "python rpc exec (full): %s"
(executable-find elpy-rpc-python-command))
(message "rpc-virtualenv-path: %s" elpy-rpc-virtualenv-path)
(message "python rpc venv location : %s" (elpy-rpc-get-or-create-virtualenv))
(with-elpy-rpc-virtualenv-activated
(message "python venv exec: %s" (executable-find elpy-rpc-python-command))))
Sorry for the delay. Evaluating the snippet (with a virtualenv
activated via pyvenv) gets me this.
python env: c:/Users/hp/Documents/projects/python/venvs/clean/
python env (env var): c:/Users/hp/Documents/projects/python/venvs/clean
python exec: python
python exec (full): c:/Users/hp/Documents/projects/python/venvs/clean/Scripts/python.exe
python rpc exec: c:/WINDOWS/py.exe
python rpc exec (full): c:/WINDOWS/py.exe
rpc-virtualenv-path: default
python rpc venv location : c:/Users/hp/.emacs.d/elpy/rpc-venv
Python path updated. Restart eglot if needed
python venv exec: c:/WINDOWS/py.exe
Summary
elpy-config
does not recognize the current virtual environmentSteps to reproduce
py
file.M-x pyvenv-workon
and select a virtualenvM-x elpy-config
My configuration
OS
I'm running Emacs 26.3 on Windows 10.
Result of
(elpy-config)
Elpy configuration in my init.el