简化的 MWE => 假设我有 Anaconda 并执行以下操作:
这告诉我"所有请求的软件包已经安装",这很好。现在,如果我决定不再需要
conda create -n demo python=3.6
conda activate demo
conda install seaborn
最后一个命令安装了39个新的软件包,包括seaborn
、matplotlib
和pandas
。现在假设时间过去了,我继续设置我的环境并希望明确地安装matplotlib
和pandas
:
conda install matplotlib pandas
这告诉我"所有请求的软件包已经安装",这很好。现在,如果我决定不再需要
seaborn
并将其移除,conda remove seaborn
这会删除安装 seaborn
时安装的全部39个软件包,包括在此之后我明确安装的 matplotlib
和 pandas
!我该如何避免这个问题?
我期望的行为是 conda remove seaborn
只删除 seaborn
及其依赖项,但不会删除任何在 seaborn
之前或之后明确安装的软件包(或其依赖项)。有些人可能会建议卸载 seaborn
和所有39个软件包,然后手动重新安装 matplotlib
和 pandas
。这在简单情况下可行,但一旦有25个具有复杂相互依赖关系的软件包,这将变得非常复杂,至少对维护来说是完全的麻烦。
作为一个具体的例子,我该如何构建一个完整的 Anaconda 环境,去掉特定的软件包以及仅包含依赖于它的软件包?我尝试过:
conda create -n test python=3.6 anaconda
conda remove libtiff # I want this to strictly only remove libtiff and its recursive dependents, but obviously this is not what happens
但第二行会移除整个环境中几乎所有的软件包,因为它会移除anaconda
。有什么想法吗?
--force-reinstall
强制执行此操作,例如对于matplotlib
,但我认为它应该默认执行)。其次,当调用conda remove
时,Conda似乎会积极地修剪显式规范。要使conda env update
命令像这样工作,需要显式添加--prune
标志,因此类似的功能应该被添加到conda remove
中。 - mervconda-meta/history
)中获取的包规范的内部列表。这些是你明确要求在你的仓库中的内容。当你运行conda env export --from-history
时,基本上会得到它的一个YAML副本。 - merv