Created
May 9, 2021 04:58
-
-
Save bc-lee/3b047700a3c4f111a34acbdfa4e9e25a to your computer and use it in GitHub Desktop.
print_python_package.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# inspired from https://stackoverflow.com/a/53805392 | |
import pkg_resources | |
try: | |
from pip import get_installed_distributions | |
except: | |
from pip._internal.utils.misc import get_installed_distributions | |
for _, package in sorted([('%s %s' % (i.location, i.key), i) for i in get_installed_distributions()]): | |
print(f"{package.key}=={package.version} # {package.location}") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment