code: def check(path_dir, requirements_name='requirements.txt'):
      '''Look for unused packages listed on project requirements'''
      requirements = _load_requirements(requirements_name, path_dir)
      imported_modules = _iter_modules(path_dir)
      installed_packages = _list_installed_packages()
  
      imported_modules.update(_excluded_imports())
  
      diff = {lib for lib in installed_packages if lib not in imported_modules}
      with_dependencies, _ = _list_dependencies(diff)
      unused_dependencies = sorted([d for d in diff if d in requirements])
  
      for unused_dependency in unused_dependencies:
          if with_dependencies.get(unused_dependency):
              print('    - {}'.format(unused_dependency))
              for dependency in with_dependencies.get(unused_dependency):
                  print('\t - {}'.format(dependency))
          else:
              print('    - {}'.format(unused_dependency)f check(path_dir, requirements_name='requirements.txt'):
      '''Look for unused packages listed on project requirements'''
      requirements = _load_requirements(requirements_name, path_dir)
      imported_modules = _iter_modules(path_dir)
      installed_packages = _list_installed_packages()
  
      imported_modules.update(_excluded_imports())
  
      diff = {lib for lib in installed_packages if lib not in imported_modules}
      with_dependencies, _ = _list_dependencies(diff)
      unused_dependencies = sorted([d for d in diff if d in requirements])
  
      for unused_dependency in unused_dependencies:
          if with_dependencies.get(unused_dependency):
              print('    - {}'.format(unused_dependency))
              for dependency in with_dependencies.get(unused_dependency):
                  print('\t - {}'.format(dependency))
          else:
              print('    - {}'.format(unused_dependency))
docs: Look for unused packages listed on project requirements