Reputation: 323
I would like to create .txt
file with all installed conda\pip packages but without version, so the list should contains numpy
not numpy==1.2.3
.
Upvotes: 1
Views: 200
Reputation: 77090
If we're going to involve Python code (e.g., @James' answer), then might as well just use the Conda API directly.
from conda.core.prefix_data import PrefixData
pkgs = sorted(r.name for r in PrefixData("/path/to/env").iter_records())
print(*pkgs, sep='\n')
If one wants Pip-installed packages to also show up, then add a True
as second argument to PrefixData
method.
Upvotes: 0
Reputation: 36746
I don't see a method in the native Conda CLI to do this. But you can accomplish it with a Python command if you want. This is platform independent.
python -c "import subprocess as s, json; j,e = s.Popen(['conda', 'list', '--json'], shell=True, stdout=s.PIPE).communicate(); list(map(lambda x: print(x['name']), json.loads(j)))" > env.txt
Upvotes: 2