8
$\begingroup$

I would like to get a list of the licenses of all packages I installed using Conda. pip has what I need in the form of pip-licenses, is there a similar thing for conda?

$\endgroup$
1
  • $\begingroup$ I proposed grep '"license":' ${CONDA_PREFIX}/conda-meta/*.json in a similar SO query. $\endgroup$
    – merv
    Jan 12 at 3:57

3 Answers 3

7
$\begingroup$

To my knowledge there's no single listing of the licenses, but you can:

conda list | awk '{if(NR>3) printf("%s=%s", $1, $2)}' | xargs conda info | grep license

Allegedly conda info --license should work, but at least in conda 4.6.3 it doesn't show any license information. It unfortunate that there's no convenient way to get a tabular list of package:version:channel:license information from the command line.

$\endgroup$
3
  • 1
    $\begingroup$ It doesn't work for me, I get InvalidVersionSpec: Invalid version '0.1.0_license=1.1_r-mutex=1.0.0_tflow_180_select=3.0_tflow_select=2.1.0absl-py=0.2.2ad3=2.2.1alabaster=0.7.10anaconda-client=1.6.14anaconda-navigator=1.8.7anaconda-project=0.8.2anyqt=0.0.8appdirs=1.4.3argcomplete=1.9.4asn1crypto=0.24.0astor=0.6.2astroid=1.6.3astropy=3.0.2atomicwrites=1.1.5attrs=18.1.0awscli=1.15.57babel=2.5.3backcall=0.1.0backports=1.0backports.sh ... etc BTW, I can edit your response, isn't that strange? Conda version 4.6.3. Conda list does not seem to output any licenses. $\endgroup$
    – Freek
    Feb 20, 2019 at 16:17
  • $\begingroup$ Try adding a \n in the printf ("%s=%s\n"). Regarding the edit, it would become a suggestion and I'd get a notice for approval. $\endgroup$
    – Devon Ryan
    Feb 20, 2019 at 16:47
  • 1
    $\begingroup$ Thanx, this does produce a list of licences indeed! However, I don't see what they belong to. I also don't understand how your command works otherwise I would distill from it something that prints a packages name and a license only. What does the command do? There are no licences in the conda list output so where do they come from? How would I get the license for one package? $\endgroup$
    – Freek
    Feb 21, 2019 at 13:56
1
$\begingroup$

This one uses JQ for parsing and querying conda generated json output (https://stedolan.github.io/jq/)

conda list | awk '{if(NR>3) printf("%s=%s\n", $1, $2)}' | xargs -I{} conda search --info --json "{}" | jq --raw-output '.[][0] | "\(.name)\t\(.version)\t\(.license)"'

builds the list, asks conda search for all info on package as json, feeds json to JQ, which selects the first item and outputs its name, version and license as tsv.

$\endgroup$
1
  • $\begingroup$ I like this solution, although it does take a bit of time, since conda search queries aren't that fast. The only problem I ran into is if you have a later version of conda installed where the command line conda is actually a function, not an executable file, you'll need to changes ... xargs -I{} conda .. to ... xargs -I{} $CONDA_EXE .... $\endgroup$ Jan 24, 2020 at 16:45
1
$\begingroup$

I can't comment, but here's an improvement for the top answer to list more information:

conda list | awk '{if(NR>3) printf("%s=%s\n", $1, $2)}' | xargs conda info | grep 'name\|version\|license'
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.