Lifecycle of conda env

139 views Asked by At

This is a bit of a theoretical question, but it's been confusing me for sometime now. I use conda for managing python and related dependencies on my machine. This is the code that I use to create a conda kernel,

conda create -n py35 python=3.5
source activate py35
conda install notebook ipykernel
ipython kernel install --user --name=python3.5

This results into (py35) getting prefixed to the command prompt. Here are my questions -

  1. What is an environment and what is a Kernel, how are the two different?

After activating an env when I run the command, jupyter notebook, it opens up a notebook where, the drop-down menu on the right displays the different envs.

  1. What is the life-cycle of this conda env. As in when I close the terminal does the env get automatically deactivated? Do I have to manually start the env everytime I restart my computer or log back in?

  2. Where do these env specific configurations live? What happens to further installs in the env. Like after activating an env if I install pandas, does it get tied to the env?

I understand the questions are a bit basic, but I'm relatively new to Python and these things have been confusing me for a while. Will really appreciate a detailed response. TIA.

1

There are 1 answers

0
Alex G Rice On BEST ANSWER

Try conda info --envs it will show you all your envs and where they live on the filesystem. You do have to reactivate an env when you sign in next time. You could add source activate my_usual_env to your .bash_profile if wanted.

After you source activate some_env then any conda install commands made be installed inside that environment only. Although it is recommended to specify as many packages as you can at the time you create the env. This way conda can resolve the library dependencies better, e.g.

conda create -n py35 python=3.5 numpy scipy biopython etc

Hope this answers at least some of your questions.