Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to analyze dependency tree for conda

Is there a tool for analyzing Conda dependencies as we do have in Maven?

ie: In Java projects (maven based) you say mvn dependency:tree and it shows all the dependencies (along with transitive dependencies) in a readable tree format.

I was wondering if we have something in python based project to analyze Conda dependencies.

Any suggestions?

like image 517
Lovey Avatar asked Apr 30 '19 00:04

Lovey


People also ask

How do you view dependencies in a conda environment?

List the dependencies that a specific package requires to run: conda search package_name --info. Find your installation's package cache directory: conda info. Find package dependencies. By default, Anaconda/Miniconda stores packages in ~/anaconda/pkgs/ (or ~/opt/pkgs/ on macOS Catalina).

How do I check the dependencies of a Python package?

Pip Check Command – Check Python Dependencies After Installation. Because pip doesn't currently address dependency issues on installation, the pip check command option can be used to verify that dependencies have been installed properly in your project. For example: $ pip check No broken requirements found.

Does conda install dependencies?

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.

Does pip check for dependencies?

The pip install <package> command always looks for the latest version of the package and installs it. It also searches for dependencies listed in the package metadata and installs them to ensure that the package has all the requirements that it needs.


1 Answers

Check out conda-tree.

Usage (based on the conda-tree webpage):

# version
$ conda-tree --version
conda-tree 0.0.4

# packages that no other package depends on
$ conda-tree leaves
['samtools','bcftools',...]

# dependencies of a specific package
$ conda-tree depends samtools
['curl', 'xz', 'libgcc', 'zlib']

# which packages depend on a specific package
$ conda-tree whoneeds xz
['samtools', 'bcftools', 'htslib', 'python']

# dependency cycles
$ conda-tree cycles
pip -> python -> pip
pip -> wheel -> python -> pip

# query a different conda prefix/env
$ conda-tree -p /conda/envs/trinity leaves
['trinity']

# query by name
$ conda-tree -n trinity leaves
['trinity']

For dependencies installed with pip, check out pipdeptree. It will return a dependency tree of the packages (installed with pip. See the documentation)

try:

pipdeptree

Or if you are looking for the leaves only

pipdeptree --freeze  --warn silence | grep -P '^[\w0-9\-=.]+'

See also this answer.

like image 124
pareyesv Avatar answered Oct 17 '22 09:10

pareyesv