As explained in pip\'s documentation a user can install packages in his personal account using pip install --user
.
How can I programmatical
Command-line:
python -c "import os, site; print(os.path.join(site.USER_BASE, 'Scripts' if os.name == 'nt' else 'bin'))"
Function:
import os, site
if os.name == 'nt':
bin_dir = 'Scripts'
else:
bin_dir = 'bin'
def get_user_install_bin_dir():
return os.path.join(site.USER_BASE, bin_dir)
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