1

I noticed that when a conda environment is created without specifying the python version:

conda create --name snowflakes 

instead of:

conda create --name snowflakes python=3.6

the environments are not separated and share the package with the default python interpreter.

Thereupon, What is the use of non-separated anaconda environments?

EDIT - 20170824: The question has been solved. Actually non-separated environments do not exist. With the first command there is no new Python interpreter installed so that it calls the first that it finds in the PATH being the standard Python interpreter because there is no other.

moth
  • 345
  • 1
  • 13
  • What do you mean by non-separated environment? When you create a new environment, it is placed in `anaconda/install/dir/envs/env-name`. There should be no packages that are shared. Can you provide an example of some code that demonstrates what you mean? – darthbith Jul 26 '17 at 14:55
  • Here: https://conda.io/docs/using/envs.html. The creation of ("standard") environment and separated environment is emphasised by standing in two separate sections and I made the test on my system. When we create a non-separated environment it shares all packages installed with the default python interpreter, unlike a separated environment. – moth Jul 26 '17 at 15:01
  • I do not see anything about sharing packages at that link. The "Create a separate environment" heading is just a wording thing. There is only one kind of conda environment, and it always has its own package set by default. Can you please show the code you used to test that all the packages are shared? – darthbith Jul 26 '17 at 16:28
  • Create a new environment with the first command, then launch Python in this environment and try to import a package that you have installed with your default Python interpreter (for example numpy). It will be available in your new non-separated environment whereas it is a new environment. Now if you carry out the same procedure with the second command (separated environment) no package will be installed (in our example there will not be the numpy package). Also compare the list of files/directories created with the first command and with the second within each environment. – moth Jul 27 '17 at 07:11
  • Please post the code that you're typing to do all of that! I tried out `conda create --name snowflakes` in my terminal with conda 4.3.22. What happened is that it created an entirely empty environment with absolutely no packages, including Python. After I activated the environment `source activate snowflakes`, I tried `which python` and it showed me `~/miniconda3/bin/python`. Therefore, I surmise that the reason the packages are all the same is not because they are shared but because you are actually running the root environment's version of Python. As for why this behavior exists... – darthbith Jul 27 '17 at 13:47
  • I think it is because the creation command should only create an environment, unless you tell it which packages to install, there will be no packages added. – darthbith Jul 27 '17 at 13:47
  • Thank you very much for your explanations. I do not post the code because it exactly is the two commands that I posted in my question. I very agree with your two latest posts, you made the same assessment as me. So, finally, according to your surmise, there is not non-separated environments? I'm fairly sure that there is, else the documentation would not distinguish the part explaining the "separated environments". But we still do not know why this behaviour exists as you said it... – moth Jul 27 '17 at 14:01
  • 1
    There must be more commands because you check the file structure, and you run python to check the imports. That's the commands I suggest including. Now, to the content, I think you are misunderstanding the word "separate" in the docs. In the docs, they mean "separate" in the sense of "create a new environment, with a new name to try some new things". They do not mean that you are creating a different kind of conda environment. There is only one kind of environment in conda, what you are calling the "separated" environment. All packages in all environments are always unique. It so happens... – darthbith Jul 27 '17 at 15:36
  • 1
    that the first command creates an *empty* environment with no packages. Therefore, when the new environment is activated, the `PATH` environment variable looks like: `~/miniconda3/envs/snowflakes/bin:~/miniconda3/bin:...` Now, since there is no Python installed into `~/miniconda3/envs/snowflakes/bin` (because the snowflakes environment is empty), the shell still finds Python in `~/miniconda3/bin` as first on the path. The `snowflakes` environment does not share with the root environment. For instance, if, after creating, you type `conda install -n snowflakes python`... – darthbith Jul 27 '17 at 15:37
  • 1
    it will install a new version of Python that won't find any packages! Therefore, there is only one kind of environment in conda, what you are calling the "separated" environment. – darthbith Jul 27 '17 at 15:39
  • 1
    Ok I have understood. Thank you very much for your time and your accurate explanations. Actually to sum up, with the first command there is no new Python interpreter installed so that it calls the first that it finds in the PATH being the standard Python interpreter because there is no other. – moth Aug 24 '17 at 13:08

1 Answers1

1

I think you are misunderstanding the word "separate" in the docs. In the docs, they mean "separate" in the sense of "create a new environment, with a new name to try some new things". They do not mean that you are creating a different kind of conda environment. There is only one kind of environment in conda, what you are calling the "separated" environment. All packages in all environments are always unique. It so happens that the first command creates an empty environment with no packages. Therefore, when the new environment is activated, the PATH environment variable looks like: ~/miniconda3/envs/snowflakes/bin:~/miniconda3/bin:... Now, since there is no Python installed into ~/miniconda3/envs/snowflakes/bin (because the snowflakes environment is empty), the shell still finds Python in ~/miniconda3/bin as first on the path. The snowflakes environment does not share with the root environment. For instance, if, after creating, you type conda install -n snowflakes python it will install a new version of Python that won't find any packages! Therefore, there is only one kind of environment in conda, what you are calling the "separated" environment.

darthbith
  • 18,484
  • 9
  • 60
  • 76