Shouldn't conda activate <env> ensure that default python, pip ect are changed to miniconda3/envs/<env>/bin?

25 views Asked by At

I am only somewhat familiar with conda. I kept having issues when trying to import modules in python, and then realised the python used by default in my active environment isn't the python in ~/miniconda3/envs/<env>, but the python found in my ~/bin/ directory.

From what I gather, the default python/pip/pip3 ect. get decided by the .bash_profile:

PATH=$PATH:$HOME/.local/bin:$HOME/bin

Is there a way to change the .bash_profile so that the default is my environment bin without hardcoding it to use the environment name (ie, the path changes depending on which environment you activate?)

EDIT: So some answers indicate their may be something specifically wrong in my setup. Here is my .bashrc:

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
alias pip=~/bin/pip3.8 
alias python=~/bin/python3.8
export PATH=/home/USERNAME/bin/:/usr/bin/:$PATH

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/USERNAME/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/USERNAME/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/home/USERNAME/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/USERNAME/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

. "$HOME/.cargo/env"

export LC_CTYPE=C

and here is my .bash_profile:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH
. "$HOME/.cargo/env"
0

There are 0 answers