Problem
How can I figure out where my site-packages directory is located?
Asked by Daryl Spitzer
Solution #1
Site-packages directories are divided into two categories: global and per-user.
Answered by Peterino
Solution #2
>>> import site; site.getsitepackages()
['/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']
(Or just use the first thing with the site.) getsitepackages()[0])
Answered by eudoxos
Solution #3
A solution that:
…is this one-liner:
python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
That looks like this when formatted for reading (rather than being used as a one-liner):
from distutils.sysconfig import get_python_lib
print(get_python_lib())
Source: an outdated version of Django’s “How to Install Django” manual (though this is useful to more than just Django installation)
Answered by Daryl Spitzer
Solution #4
For Ubuntu,
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
…is not correct.
It will direct you to the /usr/lib/pythonX.X/dist-packages directory.
This folder only includes packages that your operating system has installed for you to run programs.
The site-packages subdirectory in /usr/local/lib/pythonX.X/dist-packages on Ubuntu contains packages installed using setup toolseasy installpip.
If the use case involves installation or examining source code, the second folder is likely to be more beneficial.
If you’re not using Ubuntu, copying and pasting the first code box into the terminal should suffice.
Answered by David Hollander
Solution #5
This is what I found to be effective:
python -m site --user-site
Answered by Ramashri
Post is based on https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory