code: def main():
      
      pip_packages = {}
      for package in pip.get_installed_distributions():
          name = package.project_name
          version = package.version
          full_name = "{0}-{1}-pip".format(name.lower(), version)
          pip_packages[full_name] = {'version': version}
      data = json.dumps(pip_packages)
      print(data)
docs: Use pip to find pip installed packages in a given prefix.