I've seen some similar questions on here, but they haven't covered this particular use-case and I haven't been able to make it work on my own.

I'm trying to do the following using a script:

  1. Open a new terminal in a specific directory (and keep it open)
  2. Activate a specific conda environment in that terminal
  3. Launch my IDE (atom), also from that terminal

I've tried this:

gnome-terminal --working-directory=~/Desktop/Atom/myEnv/ -e 'conda activate myEnv && atom'

But receive this error message:

Failed to execute child process “conda” (No such file or directory)

I've also tried the following code, which results in a conda not found error:

eval "$(conda shell.bash hook)"
conda activate myEnv
bash -i

The following code opens a terminal and displays the expected python version for that environment, but doesn't carry-over the activation to the 'bash -i' window:

source ~/miniconda3/bin/activate myEnv
python --version
bash -i

Please let me know if there is a simple way to accomplish this task.

  • Is conda in your PATH? Feb 3, 2022 at 18:31
  • Yes, both "/home/nate/miniconda3/bin" and "/home/nate/miniconda3/condabin" are on the PATH
    – Mandias
    Feb 3, 2022 at 20:07

1 Answer 1


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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .