Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pip list with package urls

Tags:

python

pip

I want to get a list of installed PIP packages with the URLs to those packages.

I know that there is pip list command that lists all the packages installed, but it doesn't show the URL to package home page.

There is also pip show command that shows info about a package including its URL, but it only works for one package.

Is there a way to combine both commands to get a full list of packages with their respective home page URLs?

like image 411
Mike Milkman Avatar asked Oct 19 '17 19:10

Mike Milkman


People also ask

How do I list installed packages in pip?

To do so, we can use the pip list -o or pip list --outdated command, which returns a list of packages with the version currently installed and the latest available. On the other hand, to list out all the packages that are up to date, we can use the pip list -u or pip list --uptodate command.

What URL is pip using?

Searching for packages pip searches http://pypi.python.org/pypi by default but alternative indexes can be searched by using the --index flag.

Where does pip look for packages?

pip looks for packages in a number of places: on PyPI (if not disabled via --no-index ), in the local filesystem, and in any additional repositories specified via --find-links or --index-url .

How do I see what packages are installed in Python environment?

Start the Anaconda Navigator application. Select Environments in the left column. A dropdown box at the center-top of the GUI should list installed packages. If not, then select Installed in the dropdown menu to list all packages.


1 Answers

One way to do it is with this shell one-liner:

pip list --format=freeze | cut -d= -f1 | xargs pip show | awk '/^Name/{printf $2} /^Home-page/{print ": "$2}'

Where we simply reformatted the output of the pip show command being executed via xargs for all packages returned by pip list.

Sample output:

appdirs: http://github.com/ActiveState/appdirs
packaging: https://github.com/pypa/packaging
pip: https://pip.pypa.io/
setuptools: https://github.com/pypa/setuptools
six: http://pypi.python.org/pypi/six/
wheel: https://bitbucket.org/pypa/wheel/
like image 73
randomir Avatar answered Sep 20 '22 02:09

randomir