Ben Chuanlong Du's Blog

It is never too late to learn.

Get the Dependencies of a Python Package Without Installing It

After installing a Python package, you can use the command pip3 show pkg to check detailed information about it. What if you want to get information about a Python package without installing? The RESTAPI https://pypi.org/pypi/pkg/json returns detailed information of the Python package pkg.

Note: The recursive version of dependencies implemented bellow does not take into consideration of versions, so it might not return the correct dependencies of a Python packages.

In [1]:
!pip3 install aiutil
Defaulting to user installation because normal site-packages is not writeable
Collecting aiutil
  Downloading aiutil-0.74.0-py3-none-any.whl (44 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 44.9/44.9 KB 581.8 kB/s eta 0:00:00 0:00:01
Requirement already satisfied: numba>=0.53.0rc1 in /usr/local/lib/python3.8/dist-packages (from aiutil) (0.55.1)
Requirement already satisfied: loguru>=0.3.2 in /usr/local/lib/python3.8/dist-packages (from aiutil) (0.6.0)
Requirement already satisfied: dulwich>=0.20.24 in /usr/local/lib/python3.8/dist-packages (from aiutil) (0.20.35)
Requirement already satisfied: sqlparse>=0.4.1 in /usr/local/lib/python3.8/dist-packages (from aiutil) (0.4.2)
Requirement already satisfied: pandas-profiling>=2.9.0 in /usr/local/lib/python3.8/dist-packages (from aiutil) (3.2.0)
Requirement already satisfied: dateparser>=0.7.1 in /usr/local/lib/python3.8/dist-packages (from aiutil) (1.1.1)
Requirement already satisfied: pandas>=1.2.0 in /usr/local/lib/python3.8/dist-packages (from aiutil) (1.4.2)
Requirement already satisfied: pathspec<0.9.0,>=0.8.1 in /usr/local/lib/python3.8/dist-packages (from aiutil) (0.8.1)
Requirement already satisfied: notifiers>=1.2.1 in /usr/local/lib/python3.8/dist-packages (from aiutil) (1.3.3)
Requirement already satisfied: python-magic>=0.4.0 in /usr/local/lib/python3.8/dist-packages (from aiutil) (0.4.25)
Requirement already satisfied: toml>=0.10.0 in /usr/local/lib/python3.8/dist-packages (from aiutil) (0.10.2)
Requirement already satisfied: PyYAML>=5.3.1 in /usr/local/lib/python3.8/dist-packages (from aiutil) (6.0)
Requirement already satisfied: pytest>=3.0 in /usr/local/lib/python3.8/dist-packages (from aiutil) (7.1.2)
Requirement already satisfied: scikit-image>=0.18.3 in /usr/local/lib/python3.8/dist-packages (from aiutil) (0.19.2)
Requirement already satisfied: tqdm>=4.59.0 in /usr/local/lib/python3.8/dist-packages (from aiutil) (4.64.0)
Requirement already satisfied: GitPython>=3.0.0 in /usr/local/lib/python3.8/dist-packages (from aiutil) (3.1.27)
Requirement already satisfied: regex!=2019.02.19,!=2021.8.27,<2022.3.15 in /usr/local/lib/python3.8/dist-packages (from dateparser>=0.7.1->aiutil) (2022.3.2)
Requirement already satisfied: python-dateutil in /usr/local/lib/python3.8/dist-packages (from dateparser>=0.7.1->aiutil) (2.8.2)
Requirement already satisfied: pytz in /usr/local/lib/python3.8/dist-packages (from dateparser>=0.7.1->aiutil) (2022.1)
Requirement already satisfied: tzlocal in /usr/local/lib/python3.8/dist-packages (from dateparser>=0.7.1->aiutil) (4.2)
Requirement already satisfied: certifi in /usr/lib/python3/dist-packages (from dulwich>=0.20.24->aiutil) (2019.11.28)
Requirement already satisfied: urllib3>=1.24.1 in /usr/lib/python3/dist-packages (from dulwich>=0.20.24->aiutil) (1.25.8)
Requirement already satisfied: gitdb<5,>=4.0.1 in /usr/local/lib/python3.8/dist-packages (from GitPython>=3.0.0->aiutil) (4.0.9)
Requirement already satisfied: jsonschema<5.0.0,>=4.4.0 in /usr/local/lib/python3.8/dist-packages (from notifiers>=1.2.1->aiutil) (4.5.1)
Requirement already satisfied: requests<3.0.0,>=2.27.1 in /usr/local/lib/python3.8/dist-packages (from notifiers>=1.2.1->aiutil) (2.27.1)
Collecting click<9.0.0,>=8.0.3
  Downloading click-8.1.3-py3-none-any.whl (96 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.6/96.6 KB 1.2 MB/s eta 0:00:00a 0:00:01
Requirement already satisfied: llvmlite<0.39,>=0.38.0rc1 in /usr/local/lib/python3.8/dist-packages (from numba>=0.53.0rc1->aiutil) (0.38.0)
Requirement already satisfied: numpy<1.22,>=1.18 in /usr/local/lib/python3.8/dist-packages (from numba>=0.53.0rc1->aiutil) (1.21.6)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from numba>=0.53.0rc1->aiutil) (45.2.0)
Requirement already satisfied: matplotlib>=3.2.0 in /usr/local/lib/python3.8/dist-packages (from pandas-profiling>=2.9.0->aiutil) (3.5.2)
Requirement already satisfied: seaborn>=0.10.1 in /usr/local/lib/python3.8/dist-packages (from pandas-profiling>=2.9.0->aiutil) (0.11.2)
Requirement already satisfied: pydantic>=1.8.1 in /home/dclong/.local/lib/python3.8/site-packages (from pandas-profiling>=2.9.0->aiutil) (1.8.1)
Requirement already satisfied: missingno>=0.4.2 in /usr/local/lib/python3.8/dist-packages (from pandas-profiling>=2.9.0->aiutil) (0.5.1)
Requirement already satisfied: joblib~=1.1.0 in /usr/local/lib/python3.8/dist-packages (from pandas-profiling>=2.9.0->aiutil) (1.1.0)
Requirement already satisfied: jinja2>=2.11.1 in /usr/local/lib/python3.8/dist-packages (from pandas-profiling>=2.9.0->aiutil) (3.0.3)
Requirement already satisfied: markupsafe~=2.1.1 in /usr/local/lib/python3.8/dist-packages (from pandas-profiling>=2.9.0->aiutil) (2.1.1)
Requirement already satisfied: tangled-up-in-unicode==0.2.0 in /usr/local/lib/python3.8/dist-packages (from pandas-profiling>=2.9.0->aiutil) (0.2.0)
Requirement already satisfied: scipy>=1.4.1 in /usr/local/lib/python3.8/dist-packages (from pandas-profiling>=2.9.0->aiutil) (1.8.0)
Requirement already satisfied: multimethod>=1.4 in /usr/local/lib/python3.8/dist-packages (from pandas-profiling>=2.9.0->aiutil) (1.8)
Requirement already satisfied: htmlmin>=0.1.12 in /usr/local/lib/python3.8/dist-packages (from pandas-profiling>=2.9.0->aiutil) (0.1.12)
Requirement already satisfied: visions[type_image_path]==0.7.4 in /usr/local/lib/python3.8/dist-packages (from pandas-profiling>=2.9.0->aiutil) (0.7.4)
Requirement already satisfied: phik>=0.11.1 in /usr/local/lib/python3.8/dist-packages (from pandas-profiling>=2.9.0->aiutil) (0.12.2)
Requirement already satisfied: attrs>=19.3.0 in /usr/local/lib/python3.8/dist-packages (from visions[type_image_path]==0.7.4->pandas-profiling>=2.9.0->aiutil) (21.4.0)
Requirement already satisfied: networkx>=2.4 in /usr/local/lib/python3.8/dist-packages (from visions[type_image_path]==0.7.4->pandas-profiling>=2.9.0->aiutil) (2.8)
Requirement already satisfied: imagehash in /usr/local/lib/python3.8/dist-packages (from visions[type_image_path]==0.7.4->pandas-profiling>=2.9.0->aiutil) (4.2.1)
Requirement already satisfied: Pillow in /usr/local/lib/python3.8/dist-packages (from visions[type_image_path]==0.7.4->pandas-profiling>=2.9.0->aiutil) (9.1.0)
Requirement already satisfied: tomli>=1.0.0 in /usr/local/lib/python3.8/dist-packages (from pytest>=3.0->aiutil) (2.0.1)
Requirement already satisfied: iniconfig in /usr/local/lib/python3.8/dist-packages (from pytest>=3.0->aiutil) (1.1.1)
Requirement already satisfied: py>=1.8.2 in /usr/local/lib/python3.8/dist-packages (from pytest>=3.0->aiutil) (1.11.0)
Requirement already satisfied: packaging in /usr/local/lib/python3.8/dist-packages (from pytest>=3.0->aiutil) (21.3)
Requirement already satisfied: pluggy<2.0,>=0.12 in /usr/local/lib/python3.8/dist-packages (from pytest>=3.0->aiutil) (1.0.0)
Requirement already satisfied: tifffile>=2019.7.26 in /usr/local/lib/python3.8/dist-packages (from scikit-image>=0.18.3->aiutil) (2022.5.4)
Requirement already satisfied: imageio>=2.4.1 in /usr/local/lib/python3.8/dist-packages (from scikit-image>=0.18.3->aiutil) (2.19.0)
Requirement already satisfied: PyWavelets>=1.1.1 in /usr/local/lib/python3.8/dist-packages (from scikit-image>=0.18.3->aiutil) (1.3.0)
Requirement already satisfied: smmap<6,>=3.0.1 in /usr/local/lib/python3.8/dist-packages (from gitdb<5,>=4.0.1->GitPython>=3.0.0->aiutil) (5.0.0)
Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /usr/local/lib/python3.8/dist-packages (from jsonschema<5.0.0,>=4.4.0->notifiers>=1.2.1->aiutil) (0.18.1)
Requirement already satisfied: importlib-resources>=1.4.0 in /usr/local/lib/python3.8/dist-packages (from jsonschema<5.0.0,>=4.4.0->notifiers>=1.2.1->aiutil) (5.7.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.8/dist-packages (from matplotlib>=3.2.0->pandas-profiling>=2.9.0->aiutil) (1.4.2)
Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.8/dist-packages (from matplotlib>=3.2.0->pandas-profiling>=2.9.0->aiutil) (4.33.3)
Requirement already satisfied: pyparsing>=2.2.1 in /usr/local/lib/python3.8/dist-packages (from matplotlib>=3.2.0->pandas-profiling>=2.9.0->aiutil) (3.0.8)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.8/dist-packages (from matplotlib>=3.2.0->pandas-profiling>=2.9.0->aiutil) (0.11.0)
Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/dclong/.local/lib/python3.8/site-packages (from pydantic>=1.8.1->pandas-profiling>=2.9.0->aiutil) (3.10.0.2)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil->dateparser>=0.7.1->aiutil) (1.14.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from requests<3.0.0,>=2.27.1->notifiers>=1.2.1->aiutil) (2.8)
Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.8/dist-packages (from requests<3.0.0,>=2.27.1->notifiers>=1.2.1->aiutil) (2.0.12)
Requirement already satisfied: backports.zoneinfo in /usr/local/lib/python3.8/dist-packages (from tzlocal->dateparser>=0.7.1->aiutil) (0.2.1)
Requirement already satisfied: pytz-deprecation-shim in /usr/local/lib/python3.8/dist-packages (from tzlocal->dateparser>=0.7.1->aiutil) (0.1.0.post0)
Requirement already satisfied: zipp>=3.1.0 in /usr/local/lib/python3.8/dist-packages (from importlib-resources>=1.4.0->jsonschema<5.0.0,>=4.4.0->notifiers>=1.2.1->aiutil) (3.8.0)
Requirement already satisfied: tzdata in /usr/local/lib/python3.8/dist-packages (from pytz-deprecation-shim->tzlocal->dateparser>=0.7.1->aiutil) (2022.1)
Installing collected packages: click, aiutil
  Attempting uninstall: click
    Found existing installation: click 7.1.2
    Uninstalling click-7.1.2:
      Successfully uninstalled click-7.1.2
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
jut 0.0.24 requires click==7.1.2, but you have click 8.1.3 which is incompatible.
jut 0.0.24 requires nbformat==5.1.2, but you have nbformat 5.4.0 which is incompatible.
Successfully installed aiutil-0.74.0 click-8.1.3
WARNING: You are using pip version 22.0.4; however, version 22.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
In [2]:
from aiutil.pypi import dep
In [3]:
dep("pandas")
Out[3]:
{'numpy (>=1.18.5) ; platform_machine != "aarch64" and platform_machine != "arm64" and python_version < "3.10"',
 'numpy (>=1.19.2) ; platform_machine == "aarch64" and python_version < "3.10"',
 'numpy (>=1.20.0) ; platform_machine == "arm64" and python_version < "3.10"',
 'numpy (>=1.21.0) ; python_version >= "3.10"',
 'python-dateutil (>=2.8.1)',
 'pytz (>=2020.1)'}
In [4]:
dep("nbconvert", recursive=True)
Out[4]:
{'MarkupSafe',
 'attrs',
 'backports-functools-lru-cache',
 'beautifulsoup4',
 'bleach',
 'defusedxml',
 'entrypoints',
 'fastjsonschema',
 'importlib-metadata',
 'importlib-resources',
 'jinja2',
 'jsonschema',
 'jupyter-client',
 'jupyter-core',
 'jupyterlab-pygments',
 'mistune',
 'nbclient',
 'nbformat',
 'nest-asyncio',
 'packaging',
 'pandocfilters',
 'pygments',
 'pyparsing',
 'pyrsistent',
 'python-dateutil',
 'pywin32',
 'pyzmq',
 'six',
 'soupsieve',
 'tinycss2',
 'tornado',
 'traitlets',
 'typing-extensions',
 'webencodings',
 'zipp'}
In [5]:
dep("dockeree")
Out[5]:
{'PyYAML (>=6.0)',
 'docker (>=4.4.0)',
 'loguru (>=0.6.0)',
 'networkx (>=2.5)',
 'pandas (>=1.2.0)',
 'pygit2 (>=1.9.1)',
 'pytest (>=3.0)',
 'requests (>=2.20.0)'}
In [6]:
dep("dockeree", recursive=True)
Out[6]:
{'PyYAML',
 'aiocontextvars',
 'atomicwrites',
 'attrs',
 'cached-property',
 'certifi',
 'cffi',
 'chardet',
 'charset-normalizer',
 'colorama',
 'contextvars',
 'docker',
 'idna',
 'importlib-metadata',
 'iniconfig',
 'loguru',
 'networkx',
 'numpy',
 'packaging',
 'pandas',
 'pluggy',
 'py',
 'pycparser',
 'pygit2',
 'pyparsing',
 'pytest',
 'python-dateutil',
 'pytz',
 'pywin32',
 'requests',
 'six',
 'tomli',
 'typing-extensions',
 'urllib3',
 'websocket-client',
 'win32-setctime',
 'zipp'}

Comments