As explained in pip\'s documentation a user can install packages in his personal account using pip install --user
.
How can I programmatical
I believe the following should give the expected result
import os
import sysconfig
user_scripts_path = sysconfig.get_path('scripts', f'{os.name}_user')
print(user_scripts_path)
But it might be that pip uses a different logic internally (probably based on distutils), but the results should still be the same.
References