fgallina / python-django.el

An Emacs package for managing Django projects.
GNU General Public License v3.0
67 stars 24 forks source link

How to set python interpreter for each project using virtualenv? #20

Closed shizhz closed 9 years ago

shizhz commented 9 years ago

Hi,

I have several projects using virtualenv, how can I make the python environment setup automatically while switching projects?

Thanks :)

alep commented 9 years ago

@shizhz Did you try http://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html ?

Example I have this in a .dir-locals.el and I have one of these for each project

(
 (python-mode
  (python-shell-interpreter . "python")
  (python-shell-interpreter-args . "/home/ale/work/project/code/project/manage.py shell")
  (python-shell-prompt-regexp . "In \\[[0-9]+\\]: ")
  (python-shell-prompt-output-regexp . "Out\\[[0-9]+\\]: ")
  (python-shell-completion-setup-code . "from IPython.core.completerlib import module_completion")
  (python-shell-completion-module-string-code . "';'.join(module_completion('''%s'''))\n")
  (python-shell-completion-string-code . "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
  (python-shell-virtualenv-path . "/home/ale/.virtualenvs/env")
  )
 )
fgallina commented 9 years ago

@alep suggestion is good. I need to write some real docs :)