def get_package_name(package):
    return list(pkg_resources.get_distribution(package)._get_metadata(
        'top_level.txt'))[0]
requirements = read_requirements('/path/to/requirements.txt')
packages = [get_package_name(p) for p in requirements]
List of actuals import names in python