List Installed Python Packages
To view installed third-party libraries, you can use either of the following two methods:
1、To view installed libraries using the pip command:
pip list
This will list all the installed libraries and their version information in the current Python environment.
2. Use the pkg_resources library to view installed packages.
import pkg_resources
installed_packages = pkg_resources.working_set
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list)
This code will print a list containing all installed libraries, each library with its name and version number.