M-x pyvenv-activate <RET>
~/Documents/bitbucket-python-scripts/.env353 <RET>
works fine. Elpy Config buffer confirms that.
However with the following in ~/.emacs file
(require 'package)
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/"))
(package-initialize)
(advice-add 'python-mode :before 'elpy-enable)
(elpy-enable)
(custom-set-variables
'(elpy-rpc-python-command "python3")
'(python-shell-interpreter "python3")
'(pyvenv-activate "~/Documents/bitbucket-python-scripts/.env353"))
when I start Emacs and
M-x elpy-config
I see in the Elpy Config buffer that the virtual environment is not set. custom-set-variables were generated by Customization option of Emacs
Please point out my error.
Using: Elpy 1.28.1 Emacs 24.5.1 Debian GNU/Linux 9.8 (stretch)
UPDATED
(pyvenv-activate "~/Documents/bitbucket-python-scripts/.env353")
In ~/.emacs just after (elpy-enable) properly activate the virtual environment .env353. I have no idea why custom-set-variable command (obtained through customization) doesn't work.
custom-set-variables
sets variables whereaspyvenv-activate
is a function. If you checkC-h v
, my guess is that you now have a variable calledpyvenv-activate
whose value is the given path. Theelpy-rpc-python-command
andpython-shell-interpreter
should be okay, as those are indeed variables. Try breaking out thepyvenv-activate
statement and see how that works.pyvenv-activate
variable and function. I notice that the documentation for the variable states, "This is rarely useful to set globally", whatever that implies. It seems that thepyvenv-activate
variable only holds the path to the venv. It doesn't activate it. The function call is what activates it and that's not being called after you assign thepyvenv-activate
variable.pyvenv
needs to know the execution path forpython
, so add that path in your init file. Depends on operating system.