I wish to create new environment for a new project so that I can install various packages in it. And those packages will not then affect my base environment. My base is at 3.6.6 I want my new environment should also be of same python version. But could not do it.

Here is what I did:

conda create -n mynewenv # you must specify python version... why?
conda create -n mynewenv python=3.6.6 # so as to make it exact of 'base'. No, you can not specify 3.6.6 but only upto 3.6
conda create -n mynewenv python=3.6 # in the list to install it showed 3.6.8...why? I want only 3.6.6
conda create -n mynewenv python # somewhere I read that just by giving 'python' picks up the 'base' version. But no...it picked 3.7...why?

Please suggest correct way

1 Answers

merv On Best Solutions

One way to do this would be to dump only the Python build info from base into a requirements file, then use that for the new env creation. This would ensure that the Python is literally the same one in base.

conda list -n base --export | grep "^python=" > base-py.txt
conda create -n mynewenv --file base-py.txt

Or if you want a one-liner that avoids the temporary file:

conda create -n mynewenv --file <(conda list -n base --export | grep "^python=")