Is there a way to find all Python PyPI packages that were installed with easy_install or pip? I mean, excluding everything that was/is installed with the distributions tool
As @almenon pointed out, this no longer works and it is not the supported way to get package information in your code. The following raises an exception:
import pip
installed_packages = dict([(package.project_name, package.version)
for package in pip.get_installed_distributions()])
To accomplish this, you can import pkg_resources
. Here's an example:
import pkg_resources
installed_packages = dict([(package.project_name, package.version)
for package in pkg_resources.working_set])
I'm on v3.6.5