def get_locally_installed_packages(encoding=None):
    packages = {}
    ignore = ['tests', '_tests', 'egg', 'EGG', 'info']
    for path in sys.path:
        for (root, dirs, files) in os.walk(path):
            for item in files:
                if ('top_level' in item):
                    with open_func(os.path.join(root, item), 'r', encoding=encoding) as f:
                        package = root.split(os.sep)[(- 1)].split('-')
                        try:
                            package_import = f.read().strip().split('\n')
                        except:
                            continue
                        for i_item in package_import:
                            if ((i_item not in ignore) and (package[0] not in ignore)):
                                version = None
                                if (len(package) > 1):
                                    version = package[1].replace('.dist', '').replace('.egg', '')
                                packages[i_item] = {'version': version, 'name': package[0]}
    return packages
def get_locally_installed_packages(encoding=None):
    packages = {}
    ignore = ['tests', '_tests', 'egg', 'EGG', 'info']
    for path in sys.path:
        for (root, dirs, files) in os.walk(path):
            for item in files:
                if ('top_level' in item):
                    with open_func(os.path.join(root, item), 'r', encoding=encoding) as f:
                        package = root.split(os.sep)[(- 1)].split('-')
                        try:
                            package_import = f.read().strip().split('\n')
                        except:
                            continue
                        for i_item in package_import:
                            if ((i_item not in ignore) and (package[0] not in ignore)):
                                version = None
                                if (len(package) > 1):
                                    version = package[1].replace('.dist', ).replace('.egg', )
                                packages[i_item] = {'version': version, 'name': package[0]}
    return packages