I know there is a command pip show
for the purpose but I would like to know whether it is possible I can fetch details by doing import pip
? When you run pip show
it gives info like:
pip show requests
Name: requests
Version: 2.26.0
Summary: Python HTTP for Humans.
Home-page: https://requests.readthedocs.io
Author: Kenneth Reitz
Author-email: [email protected]
License: Apache 2.0
Location: /anaconda3/lib/python3.7/site-packages
Requires: urllib3, certifi, charset-normalizer, idna
Required-by: yarg, wordpress-api, WooCommerce, web3, vvm, tweepy, tika, stellar-sdk, stellar-base-sseclient, Sphinx, spacy, smart-open, requests-toolbelt, requests-oauthlib, requests-html, python3-nmap, python-binance, pyArango, poetry, pigar, pandas-datareader, MechanicalSoup, mara-pipelines, kubernetes, ipfshttpclient, hdfs, google-cloud-storage, google-api-core, discum, conda, conda-build, ccxt, CacheControl, browsermob-proxy, bravado, apache-beam, anaconda-project, anaconda-client, alpha-vantage, facebook-sdk
I need data in Required-by
field.
2
Answers
Playing with pip source code, I found the following solution
which works for Python 3.8.1 and pip 21.0.1 .
Example output (it is dependent on the used python environment)
Or better to use current runtime:
Answer is inspired (overworked) by this answer