Search code examples
pythoncondaenvironmenttmuxminiconda

Deactivating automatically conda and miniconda virtual environment when using a tmux session


I would like to automatically deactivate the conda and Miniconda environment when running a new tmux session.

Right now, this is the situation:

userk@dopamine:~$ which python
/usr/bin/python
userk@dopamine:~$ tmux
(base) userk@dopamine:~$
(base) userk@dopamine:~$ which python
/home/userk/miniconda3/bin/python
(base) userk@dopamine:~$ conda deactivate
userk@dopamine:~$

I have noticed the conda script file in ~/miniconda3/etc/profile.d/conda.sh, maybe it is involved in this problem. But I am not sure and I would wait for your suggestions.

I have commented out all lines in the .bashrc file related to conda. Same issue..

# added by Anaconda3 installer
#export PATH="/home/userk/development/anaconda3/bin:$PATH"

# added by Anaconda3 installer
#export PATH="/home/userk/anaconda3/bin:$PATH"
# added by Miniconda3 4.5.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
#__conda_setup="$(CONDA_REPORT_ERRORS=false '/home/userk/miniconda3/bin/conda' shell.bash hook 2> /dev/null)"
#if [ $? -eq 0 ]; then
#    \eval "$__conda_setup"
#else
#    if [ -f "/home/userk/miniconda3/etc/profile.d/conda.sh" ]; then
#        . "/home/userk/miniconda3/etc/profile.d/conda.sh"
#        CONDA_CHANGEPS1=false conda activate base
#    else
#        \export PATH="/home/userk/miniconda3/bin:$PATH"
#    fi
#fi
#unset __conda_setup
# <<< conda init <<<
#conda deactivate

I am forced to execute the conda deactivate command in each new tmux session. Is it possible to fix this problem?


Solution

  • Ok cool! As stated in this question and underlined here, the bash_profile should be checked as well. I commented out the lines related to the virtual environment and problem solved!