Sunday, February 21, 2010

Programmer - Specifying python interpreter from virtualenv in emacs

Programmer Question

Today I've been trying to bring more of the python related modes into
my emacs configuration but I haven't had much luck.



First what I've noticed is that depending on how emacs is
launched(terminal vs from the desktop), the interpreter it decides to
use is different.




  • launched from kde menu: M-! which python --> /usr/bin/python


  • launched from terminal: M-! which python -->~/local/bin/python




I can kind of accept this since I have my .bashrc appending
~/local/bin to the path and I guess kde ignores that by default.I can
work around this, however what I don't understand is then if I
activate a virtualenv, I would expect M-! which python to point to
~/project.env/bin/python however it still points to ~/local/bin/python



Thus when I M-x py-shell, I get ~/local/bin/python so if I try to
py-execute-buffer on a module that resides in a package in the
virtualenv, py-shell will complain about not knowing about modules
also in the virtualenv.



Setting py-python-command to ~/project.env/bin/python seems to have no
effect after everything is loaded.



So I guess the overall crux of my question is, how does one get all
the python related emacs stuff pointing at the right interpreter?

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails