How do I find the location of my site-packages directory?
As others have noted, distutils.sysconfig
has the relevant settings:
import distutils.sysconfig
print distutils.sysconfig.get_python_lib()
...though the default site.py
does something a bit more crude, paraphrased below:
import sys, os
print os.sep.join([sys.prefix, 'lib', 'python' + sys.version[:3], 'site-packages'])
(it also adds ${sys.prefix}/lib/site-python
and adds both paths for sys.exec_prefix
as well, should that constant be different).
That said, what's the context? You shouldn't be messing with your site-packages
directly; setuptools/distutils will work for installation, and your program may be running in a virtualenv where your pythonpath is completely user-local, so it shouldn't assume use of the system site-packages directly either.