Python Forum
Is it possible to see dependencies before installing a package? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Is it possible to see dependencies before installing a package? (/thread-38878.html)



Is it possible to see dependencies before installing a package? - quazirfan - Dec-06-2022

I want to see the list of dependencies(packages) a given package depends on before installing the package.

For example, pandas depend on numpy. Is there a pip command that takes pandas as input and shows me the dependencies that will be installed alongside pandas? It would be best if the dependency tree is recursive - meaning dependencies also show their dependencies.

Thank you!


RE: Is it possible to see dependencies before installing a package? - quazirfan - Dec-06-2022

I found this SO answer that points to some workarounds: https://stackoverflow.com/questions/29751572/how-to-find-a-python-packages-dependencies

It appears this was not a high-priority feature for pip developers.


RE: Is it possible to see dependencies before installing a package? - snippsat - Dec-06-2022

Can use Johnnydep
Example Pandas.
C:\code
λ johnnydep pandas
2022-12-06 11:26:22 [info     ] init johnnydist                [johnnydep.lib] dist=pandas parent=None
2022-12-06 11:26:25 [info     ] init johnnydist                [johnnydep.lib] dist=numpy>=1.21.0 parent=pandas
2022-12-06 11:26:28 [info     ] init johnnydist                [johnnydep.lib] dist=python-dateutil>=2.8.1 parent=pandas
2022-12-06 11:26:30 [info     ] init johnnydist                [johnnydep.lib] dist=pytz>=2020.1 parent=pandas
2022-12-06 11:26:32 [info     ] init johnnydist                [johnnydep.lib] dist=six>=1.5 parent=python-dateutil>=2.8.1
name                        summary
--------------------------  -----------------------------------------------------------------------
pandas                      Powerful data structures for data analysis, time series, and statistics
├── numpy>=1.21.0           NumPy is the fundamental package for array computing with Python.
├── python-dateutil>=2.8.1  Extensions to the standard Python datetime module
│   └── six>=1.5            Python 2 and 3 compatibility utilities
└── pytz>=2020.1            World timezone definitions, modern and historical
Example scikit-learn
C:\code
λ johnnydep scikit-learn
2022-12-06 11:30:23 [info     ] init johnnydist                [johnnydep.lib] dist=scikit-learn parent=None
2022-12-06 11:30:26 [info     ] init johnnydist                [johnnydep.lib] dist=joblib>=1.0.0 parent=scikit-learn
2022-12-06 11:30:27 [info     ] init johnnydist                [johnnydep.lib] dist=numpy>=1.17.3 parent=scikit-learn
2022-12-06 11:30:31 [info     ] init johnnydist                [johnnydep.lib] dist=scipy>=1.3.2 parent=scikit-learn
2022-12-06 11:31:15 [info     ] init johnnydist                [johnnydep.lib] dist=threadpoolctl>=2.0.0 parent=scikit-learn
2022-12-06 11:31:17 [info     ] init johnnydist                [johnnydep.lib] dist=numpy<1.26.0,>=1.18.5 parent=scipy>=1.3.2
name                           summary
-----------------------------  -----------------------------------------------------------------
scikit-learn                   A set of python modules for machine learning and data mining
├── joblib>=1.0.0              Lightweight pipelining with Python functions
├── numpy>=1.17.3              NumPy is the fundamental package for array computing with Python.
├── scipy>=1.3.2               Fundamental algorithms for scientific computing in Python
│   └── numpy<1.26.0,>=1.18.5  NumPy is the fundamental package for array computing with Python.
└── threadpoolctl>=2.0.0       threadpoolctl



RE: Is it possible to see dependencies before installing a package? - quazirfan - Dec-06-2022

Thanks. It was mentioned in the original SO answer, but Johneydep has its dependencies. I was looking for a pip command because I wanted to add packages carefully to my environment.


RE: Is it possible to see dependencies before installing a package? - snippsat - Dec-06-2022

(Dec-06-2022, 02:26 PM)quazirfan Wrote: I was looking for a pip command because I wanted to add packages carefully to my environment
The way to solve this that is to use virtual environment.
Example i would not at install eg some these AI libraries eg in this post whisper without using virtual environment.
Don't need it anymore if just delete whisper_env folder,then all is gone.
I did help someone at one time the libraries did install 100 packages.

I have of course a lot install to the root Python,but to test larger libraries to avoid conflicts should use virtual environment.
Also if i make a package/libraries myself the this is done in a virtual environment.
There are ok 3-party like Poetry it work fine,my only complain that it need a lot dependencies itself.

Here a packages in Whisper,dos not matter what i have installed before this is now isolated.
(whisper_env) G:\div_code\whisper_env
λ pip list
Package            Version
------------------ ----------
certifi            2022.9.24
charset-normalizer 2.1.1
colorama           0.4.6
ffmpeg-python      0.2.0
filelock           3.8.0
future             0.18.2
huggingface-hub    0.11.1
idna               3.4
more-itertools     9.0.0
numpy              1.23.5
packaging          21.3
pip                22.0.4
pyparsing          3.0.9
PyYAML             6.0
regex              2022.10.31
requests           2.28.1
setuptools         58.1.0
tokenizers         0.13.2
torch              1.13.0
tqdm               4.64.1
transformers       4.25.1
typing_extensions  4.4.0
urllib3            1.26.13
whisper            1.0