When working on multiple projects, I usually create a new conda environment to work with for each project.
For example, I use the following commands to create "projectA" environment:
conda create -n projectA python=3.6 pip
I also use separate tmux session for each project. But when I enter to tmux, and create new pane or new windows, I have to
conda activate projectA. I feel it too slow and inconvenience. So, I put those below line into .bashrc file:
conda activate $CONDA_DEFAULT_ENV
It works very good, the FIRST tmux session inherits the environment of the current shell. But I met a problem with when I create SECOND tmux session, it inherit environment variables from the FIRST session, not current shell.
- Step 1: Create shell (base enviroment), activate "projectA" environment.
- Step 2: Create tmux session 0, it's in "projectA" environment.
- Step 3: Create a new pane in session 0, it's still in "projectA" environment.
- Step 4: Create another shell (base environment), activate "projectB" environment.
- Step 5: Create tmux session 1, it's in "projectA" environment. (while I was hoping it's in "projectB" environment. Why? and how to achieve what I was hoping?
I try to use "printenv | grep CONDA" to debug the environments varibles, at step 4, it produce:
CONDA_SHLVL=2 CONDA_EXE=/home/z/anaconda3/bin/conda CONDA_PREFIX=/home/z/anaconda3/envs/projectB CONDA_PREFIX_1=/home/z/anaconda3 CONDA_PYTHON_EXE=/home/z/anaconda3/bin/python _CE_CONDA= CONDA_PROMPT_MODIFIER=(projectB) CONDA_DEFAULT_ENV=projectB
at step 5, it produce:
CONDA_SHLVL=2 CONDA_EXE=/home/z/anaconda3/bin/conda CONDA_PREFIX=/home/z/anaconda3/envs/projectA CONDA_PREFIX_1=/home/z/anaconda3 CONDA_PYTHON_EXE=/home/z/anaconda3/bin/python _CE_CONDA= CONDA_PROMPT_MODIFIER=(projectA) CONDA_DEFAULT_ENV=projectA