I have anaconda environments for python2 and python3 as I have code written in the different versions

In spacemacs (with python layer installed), when I open ipython (SPC m s i) it starts with my default environment (python 3)

Is there a way to choose which version of python I run my code with? I've tried opening a shell with activate python2 to activate my other environment, but ipython in emacs still opens with my default

One way I've found is to activate the environment is SPC m V a then navigate to the directory where the venv is, but this is quite tedious as the python script and venv are often on different drives so it takes a fair bit of typing/tabbing to get to the venv directory

Is there a quicker way?

2 Answers 2


Basically, this is a duplicate of this question. Reproducing the proposed behavior with spacemacs, I changed my user-init to:

(defun dotspacemacs/user-init ()
  (setenv "WORKON_HOME" "/home/<username>/.local/bin/anaconda3/envs")

After reloading my .spacemacs file with SPC f e R, I'm immediately able to use , V w and select environments from my anaconda installation.

  • 1
    , v w for me.
    – HappyFace
    Commented Aug 19, 2019 at 18:49
  • 1
    Once I switch conda environments, If I do SPC m c c to run my script, it still uses my base environment. Any ideas how to run with the selected environment?
    – Austin
    Commented Jan 30, 2020 at 20:53

Full process to make running SPC m c c inside a conda env work on Windows:

# install both layers in the dotfile
... add the 2 lines below
(python :variables python-shell-interpreter "c:/path/to/conda/envs/ds/python.exe")
(conda :variables conda-anaconda-home "c:/path/to/conda")

# setup pyvenv in user-init
(defun dotspacemacs/user-init ()
... add the 2 lines below
  (setenv "WORKON_HOME" "d:/progs/mambaforge/envs")
  (pyvenv-mode 1)

# then open python file and make sure all the modes are active (run them)

# select environment in pyvenv and conda

Finally SPC m c c runs inside the environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.