How do I find the location of my Python site-packages directory?

You can use the site module to find the location of your Python site-packages directory. Here is a code snippet that you can use:

import site
site.getsitepackages()

This will return a list of directories where site-packages are located, you can use the first one or the one that best fits your needs.

Watch a course Python - The Practical Guide

Alternatively, you can also use sys.prefix to find the location of the site-packages directory.

import sys
print(sys.prefix)

This will give you the base prefix path and you can append /lib/python3.X/site-packages where X is your python version.