简体   繁体   中英

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

Very obviously, in this case, there are only two top-level dependencies that are added in this environment: python and Jupiter.

I know that we can export the dependencies according to Sharing an environment

conda env export > environment.yml

But see how verbose it is.

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. 

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

There is currently no way of doing this automatically using the conda system.

There is an open issue on the conda GitHub page that explores a similar scenario (finer control over environment exports). As of 18-06-2019 this issue is open.

您可以使用一个--from-history标志,它将仅显示已明确安装的软件包,并应提供您想要的内容:

conda env export --from-history > environment.yml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM