title: Programmatically determine pip 'user install' location Scripts directory
body: <p>As explained in <a href="https://pip.pypa.io/en/stable/user_guide/#user-installs" rel="noreferrer">pip's documentation</a> a user can install packages in his personal account using <code>pip install --user &lt;pkg&gt;</code>. </p>
  
  <p>How can I programmatically determine the user install location for scripts installed like this? I am talking about the directory that should be added to the PATH so that installed packages can be invoked from command line.</p>
  
  <p>For example, in Windows when installing <code>pip install -U pylint --user</code> I get the following warning because I don't have <code>'C:\Users\myusername\AppData\Roaming\Python\Python37\Scripts'</code> in my PATH:</p>
  
  <pre><code>...
  Installing collected packages: wrapt, six, typed-ast, lazy-object-proxy, astroid, mccabe, isort, colorama, toml, pylint
    Running setup.py install for wrapt ... done
    WARNING: The script isort.exe is installed in 'C:\Users\myusername\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.
    Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
    WARNING: The scripts epylint.exe, pylint.exe, pyreverse.exe and symilar.exe are installed in 'C:\Users\myusername\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.
  </code></pre>
  
  <p>Is there some python code I can use to determine that location programmatically (that will work on Windows/Linux/Darwin/etc)? Something like:</p>
  
  <pre><code>def get_user_install_scripts_dir():
      ...
      # would return 'C:\Users\myusername\AppData\Roaming\Python\Python37\Scripts'
      # on Windows with Python 3.7.x, '/home/myusername/.local/bin' in Linux, etc
      return platform_scripts_dir
  </code></pre>
  
  <p>As a fallback, is there some command I can run to obtain this location? Something like (but for the script location not the site's base directory):</p>
  
  <pre><code>PS C:\Users\myusername\&gt; python -m site --user-base
  C:\Users\myusername\AppData\Roaming\Python
  
  $ python -m site --user-base
  /home/myusername/.local
  </code></pre>