显示conda托管环境的顶级依赖关系 [英] Show top level dependencies for a conda managed environment
问题描述
作为一个例子,如果我创建了一个新环境.
Just as an example, if I created a new environment.
conda install python
conda create --name foo_environment
conda activate foo_environment
conda install python
conda install jupyter
conda env export > environment.yml
很显然,在这种情况下,在此环境中仅添加了两个顶级依赖项:python和Jupiter.
Very obviously, in this case, there are only two top-level dependencies that are added in this environment: python and Jupiter.
我知道我们可以根据但是看看它有多详细.
name: foo_environment
channels:
- defaults
- conda-forge
dependencies:
- appnope=0.1.0=py37_0
- attrs=19.1.0=py37_1
- backcall=0.1.0=py37_0
- bleach=3.1.0=py37_0
- ca-certificates=2019.5.15=0
- certifi=2019.3.9=py37_0
- dbus=1.13.6=h90a0687_0
...and 70 more lines here.
有没有一种方法只能导出顶级依赖项?我知道我可以像下面这样手动创建yml文件.但是手动执行操作有点烦人.有什么方法可以自动导出顶级依赖项?
Is there a way to only export the top level dependencies? I know I can manually create the yml file like this below. But doing things manually is a bit annoying. Any way to export the top level dependencies automatically?
name: foo_environment
channels:
- defaults
- conda-forge
dependencies:
- python=3.7.3
- jupyter=1.0.0
推荐答案
有一个标志-from-history
可以使用,它只会显示已明确安装的软件包,并且应该为您提供什么你想要的:
There is a flag --from-history
you can use that will only show packages that were explicitly installed and should give you what you want:
conda env export --from-history > environment.yml
这篇关于显示conda托管环境的顶级依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!