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
Conda provides many of the features found in pip, virtualenv, venv and pyenv. However it is a completely separate tool that will manage Python dependencies differently, and only works in Conda environments. Conda analyzes each package for compatible dependencies, and how to install them without conflict.
conda list --explicit does not include any pip -installed packages, while conda list does.
Built into Anaconda, conda is a powerful package manager and environment manager that you use with command-line in the Anaconda Prompt for Windows, or in a terminal window for macOS or Linux. pip is the standard package manager for python, meaning you can use it both inside and outside of Anaconda.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With