You can use bash
,zsh
or any shell aliases for this purposes. You just add
alias my_conda='source /home/$USER/anaconda3/bin/activate && conda activate MyPy38'
line into the .bashrc
,.zshrc
or .any_other_shell_rc
.
"N.B. My environment name is MyPy38
". So,replace it according name as well as the path /home/$USER/anaconda3
.
Also you can create separate file for aliases. Just create a file called .bash_aliases
and add
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
lines to .bashrc
,.zshrc
or .any_other_shell_rc
and keep the command
alias my_conda='source /home/$USER/anaconda3/bin/activate && conda activate MyPy38'
into the .bash_aliases
. Now, source ~/.zshrc ~/.bashrc
or just close and open a new terminal. Run the command my_conda
and BOOM!
Also, you can add some other aliases for jupyter-notebook
jupyter-lab
spyder
etc. like
# Just activate my conda
alias my_conda='source /home/$USER/anaconda3/bin/activate && conda activate MyPy38'
# Open Jupyter Notebook in my Env
alias my_jupn='source /home/$USER/anaconda3/bin/activate && conda activate MyPy38 && jupyter-notebook'
# Open Jupyter Lab in my Env
alias my_jupl='source /home/$USER/anaconda3/bin/activate && conda activate MyPy38 && jupyter-lab'
# Open Spyder in my Env
alias my_spyder='source /home/$USER/anaconda3/bin/activate && conda activate MyPy38 && spyder'
To confirm active environment name python code
import sys
print(sys.executable)