1

What is the best way to load in emacs the environment variables of a virtualenv?

I seem to have got virtualenvwrapper.el working. For example, after using venv-workon my_venv, then M-! printenv shows that the environment variable VIRTUAL_ENV has been set to my_venv. Likewise, different virtualenvs load different python versions.

It also seems that I've got the package exec-path-from-shell.el working. For example, in the terminal outside of any virtualenv the command printenv shows MY_ENV_VARIABLE=oy. Now after doing (exec-path-from-shell "MY_ENV_VARIABLE") inside emacs, M-! printenv confirms that MY_ENV_VARIABLE=oy inside emacs as well.

So, I tried doing venv-workon my_venv and then exec-path-from-shell MY_VENV_VARIABLE, which has been set in my_venv. Then, exec-path-from-shell seems to find the value of MY_VENV_VARIABLE to be nil while actually it is voy.

mmw
  • 111
  • 3
  • 1
    Well... there are too many unknowns... but a relatively easy way to achieve something like this (w/o using third-party packages) would be to parse the output of `printenv` and use the results with `(setenv "variable-name" "variable-value")`. – wvxvw Dec 22 '16 at 09:27
  • 1
    See also [Reload environment variables](http://emacs.stackexchange.com/questions/6104/reload-environment-variables/6107#6107) – Håkon Hægland Dec 22 '16 at 13:33
  • Ah i see! So the strategy I'd tried is really a nonstarter. But the workaround in that linked answer ...works :). Thank you. – mmw Dec 23 '16 at 02:33

0 Answers0