Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to activate the ananconda's env python in emacs?

I install the python3.5 and python 2.7 in anaconda. the anaconda manager python version and package is convenvient. activate pyx.x in win10's cmd. In emacs's python-mode, c-c c-p (start interpreter) only open the default python version. how switch python version ?

like image 513
user3193980 Avatar asked May 26 '16 23:05

user3193980


1 Answers

You didn't seem to explain your self much so I'm going to try and guess what you want.

You want to be able to switch conda python versions and conda virtual environments depending on what files you're editing. I recently set this up using the pyvenv package. In my config file I have:

(use-package pyvenv
        :ensure t
        :init
        (setenv "WORKON_HOME" "/home/NAME/anaconda/envs")
        (pyvenv-mode 1)
        (pyvenv-tracking-mode 1))

Change the "WORKON_HOME" directory to point to the directory with your virtual environments.

Then in your project directory. Place a file called .dir-locals.el in that file place: ((nil . ((pyvenv-workon . "ENV_NAME")))) where ENV_NAME should be replaced by your virtual-environments name.

Your project tree should look like:

-Project
  -projectfile_1.py
  -projectfile_2.py
  -.dir-locals.el

If that doesn't help let me know

like image 95
Jules Avatar answered Nov 14 '22 13:11

Jules