def pip_licenses_df(package_names=None, include_module_name=True, on_module_search_error=None):
    '\n    Get a dataframe of pip packages and licences\n    :return:\n    '
    pip_licenses_output = subprocess.check_output(['pip-licenses'])
    t = list(map(str.strip, list(filter(word_or_letter_p.search, pip_licenses_output.split('\n')))))
    t = [at_least_two_spaces_p.sub('\t', x) for x in t]
    t = '\n'.join(t)
    df = pd.read_csv(StringIO(t), sep='\t')
    df = df.rename(columns={'Name': 'package_name', 'Version': 'version', 'License': 'license'})
    if include_module_name:
        df['module'] = [get_module_name(x, on_error=on_module_search_error) for x in df['package_name']]
        df = df[['module', 'package_name', 'version', 'license']]
    if (package_names is not None):
        df = df[df['package_name'].isin(package_names)]
    return df
Get a dataframe of pip packages and licences
:return:
def pip_licenses_df(package_names=None, include_module_name=True, on_module_search_error=None):
    '\n    Get a dataframe of pip packages and licences\n    :return:\n    '
    pip_licenses_output = subprocess.check_output(['pip-licenses'])
    t = list(map(str.strip, list(filter(word_or_letter_p.search, pip_licenses_output.split('\n')))))
    t = [at_least_two_spaces_p.sub('\t', x) for x in t]
    t = '\n'.join(t)
    df = pd.read_csv(StringIO(t), sep='\t')
    df = df.rename(columns={'Name': 'package_name', 'Version': 'version', 'License': 'license'})
    if include_module_name:
        df['module'] = [get_module_name(x, on_error=on_module_search_error) for x in df['package_name']]
        df = df[['module', 'package_name', 'version', 'license']]
    if (package_names is not None):
        df = df[df['package_name'].isin(package_names)]
    return df