For installing third-party Python packages I have used a setup.py script that uses setuptools.setup() to install a bunch of packages. After the installation I can find these packages on one machine under /usr/local/lib/python2.7/dist-packages and on another machine under /usr/lib/python2.7/site-packages.

Now I want to write a Python script that finds out where the third-party packages have been installed. How can I do that?

1) sys.prefix=sys.exec\_prefix is on both machines "/usr".

2) The python executable is on both machines /usr/bin/python.

3) distutils.sysconfig.get\_python\_lib() is /usr/lib/python2.7/dist-packages ("local" is missing) on one machine and /usr/lib/python2.7/site-packages on the other machine.