无法使用与“ base”相同的python版本创建新的conda环境

时间:2019-05-10 02:16:29

标签: python conda virtual-environment

我希望为新项目创建新环境,以便可以在其中安装各种软件包。这些软件包将不会影响我的基本环境。 我的基数是3.6.6 我希望我的新环境也应该是相同的python版本。但是做不到。

这是我所做的:

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?

请提出正确的方法

1 个答案:

答案 0 :(得分:1)

执行此操作的一种方法是仅将 base 中的Python构建信息转储到需求文件中,然后将其用于新的env创建。这样可以确保Python在 base 中实际上是相同的。

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

或者如果您想要一种避免使用临时文件的单线纸:

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