If I open a new eshell when having a virtual env activated the eshell does not recognize the virtual environment. Is this supposed to work or have I configured elpy incorrectly?
Regards, Micke.
Opening a shell (M-x shell instead of M-x eshell) works, the new shell uses the activated virtual environment.
Hello, and thanks for the report! This is strange. pyvenv sets exec-path, which should affect eshell, too. How do you notice that eshell is not recognizing the virtualenv?
I have tried to illustrate all this in a screenshot, I hope you can see all the info.

Does M-: (executable-find "python") find the Python interpreter in the virtualenv?
It seem so. I evaluated (executable-find "python") in the scratch buffer and printed the result. At the same time eshell finds my system installed python, not the one in the virtualenv.

This is even more strange; executable-find evaluated in eshell returns the python in the virtualenv but the python command in eshell returns the system wide installed python.

That seems to be a problem of eshell, I'm afraid …
@clearmisp I recommend using https://github.com/porterjamesj/virtualenvwrapper.el if you're using virtualenvwrapper. I've been using ti for a while and it works
Hm. I'd be curious what virtualenvwrapper.el does that pyvenv.el does not, because Elpy recommends the latter. And I wrote the latter because there was nothing around that really worked well back then. If that changed, Elpy might want to switch suggested venv packages. Or some features could be added to pyvenv.
virtualenvwrapper will only work on eshell, it doesn't affect anything else. So pyenv is still the better route to go
Oh. That's interesting, thank you :-)
It would seem that there is a missing eshell-modify-global-environment for pyvenv to work. The following works for me:
(setq eshell-modify-global-environment t)
(defun smf/post-venv-hook ()
(setq eshell-path-env (mapconcat 'identity exec-path ":")))
(add-hook 'pyvenv-post-activate-hooks #'smf/post-venv-hook)
(add-hook 'pyvenv-post-deactivate-hooks #'smf/post-venv-hook)
It even works after the eshell buffer has started :-)
Nice. Filed a feature request with pyvenv. I won't be able to work on this in the near future, so any help would be welcome :-)
It would seem that there is a missing
eshell-modify-global-environmentfor pyvenv to work. The following works for me:(setq eshell-modify-global-environment t) (defun smf/post-venv-hook () (setq eshell-path-env (mapconcat 'identity exec-path ":"))) (add-hook 'pyvenv-post-activate-hooks #'smf/post-venv-hook) (add-hook 'pyvenv-post-deactivate-hooks #'smf/post-venv-hook)It even works after the eshell buffer has started :-)
this didn't work for me but virtualenvwrapper did.
Apparently the associated PR in pyvenv has been merged.