Windows: AppData, Roaming vs Local

I have installed Python 3.8 on Windows 10, user install, not WSL and pipx (using pip) and was confused when I was informed during the install process that pipx’s commands were not on the path.

The reason it turns out is that pipx has installed in \AppData\Roaming\Python\Python38\Scripts

But Python has installed in \AppData\Local\Programs\Python\Python38\

and therfore the Scripts directory which has been added to the path is \AppData\Local\Programs\Python\Python38\Scripts

I’m currently browsing the pip source code but with the pip/setuptools/distutils unholy trinity it may take me some time to work my way through the 9 circles :wink:

Can anyone confirm my suspicion that this is ultimately because _getuserbase() in site.py used os.environ.get("APPDATA").

If so, is this “as designed” (and I should add both Local and Roaming to the PATH) or a bug due to a mismatch between site.py and the installer, or something else?

From my understanding this is deliberately designed. A --user install always goes to Roaming, and non-user goes to the Python installation’s scripts directory (that’s Local if Python is installed per-user). So yes, you’d want to add the roaming path to PATH is this case.

I found a thread mentioning this behaviour and some confusion it causes: https://github.com/pypa/pip/issues/7209

Thank you, so my mistake was that a Windows “Per User” install is not a --user install and installing without --user will get everything installed in the “Local” tree and the PATH manipulation provided by the installer will work.

That is correct. I (personally) recommend against adding the Local tree to PATH, but that’s a different topic altogether :stuck_out_tongue: