import pip
from os.path import join
for package in pip.get_installed_distributions():
print(package.location) # you can exclude packages that's in /usr/XXX
print(join(package.location, package._get_metadata("top_level.txt"))) # root directory of this package