2

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 Answers1

1

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=")
merv
  • 67,214
  • 13
  • 180
  • 245
  • Only the python version needs to be same as 'base'...rest of the packages would be different in the new env... – Yogesh Haribhau Kulkarni May 10 '19 at 04:54
  • @Yogesh yes, that's exactly what this does. – merv May 10 '19 at 05:08
  • base-py.txt stored "python==3.6.6=he025d50_0" ..when tried to create new env with this it said Package Not Found in the current channels...should I add some specific channels before? – Yogesh Haribhau Kulkarni May 10 '19 at 05:13
  • @Yogesh looks like [it's a Conda Forge build](https://anaconda.org/conda-forge/python/files?version=3.6.6). If you add `-c conda-forge` flag to the create command, then it should work. Or you can [add Conda Forge permanently](https://conda-forge.org/#about). – merv May 10 '19 at 05:22