Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tmux recognised Conda env but still use the default python

I have trouble using anaconda environment in Tmux. I am on OSX.

I first

tmux 

Then activate the Conda env:

conda activate myenv

At this point when I conda info shows the correct active environment and correct location. But which python still points to the default /usr/bin/python.

In the .bash_profile I have these lines added by anaconda when installed. So I guess I need to add something to let the terminal find the right python path?

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

Thank you for your suggestion.

like image 659
J_yang Avatar asked Aug 26 '19 14:08

J_yang


People also ask

How do you set Anaconda environment as default?

Go to the start menu, right-click 'Anaconda Prompt' and go to file location. Open its properties & change the target to the location of your preferred environment.

How do I change Python interpreter to Conda?

Open up your terminal. Search for available versions - can search for what you want, but we'll look for “python” > conda search python which returns something like this: Fetching package metadata: . To change your python version, you can now just type: conda install python=3.5.


1 Answers

Below works for me on macOS 10.15 with zsh:

Add below line to your ~/.tmux.conf file

set -g default-command "/bin/zsh"

If you're using a shell other than zsh, I assume changing the path to the shell you're using will also work.

like image 83
Dyckia Avatar answered Sep 28 '22 02:09

Dyckia