I need to get the location of an installed package (i.e. from "site-packages" or "dist-packages"), but I may be inside the package's directory itself.
I have tried everything from both of these questions, and some problems inevitably arise.
I have tried pip.get_installed_distributions()
, and this is very close, but there is no guarantee that the package will have been installed with pip. If the package is not installed with pip, then get_installed_distributions()
doesn't return the package.