Environment paths


On Windows 11, I installed Python 3.11 for all users and ensured the setup would set the environmental paths. Yet, when I do a pip install, I get the error message below:

WARNING: The scripts jupyter-bundlerextension.exe, jupyter-nbextension.exe, jupyter-notebook.exe and jupyter-serverextension.exe are installed in ‘C:\Users\John\AppData\Roaming\Python\Python311\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.

If I add the %USERPROFILE%\AppData\Roaming\Python\Python311\Scripts to the environment path, the error message goes away. Yet, I cannot launch Jupyter from any folder, I have to browse to that path and run it from there. What have I done wrong? In the meantime, I will install Python for one user, but this is somehow annoying.

Thank you!

1 Like

“%AppData%\Python\Python311\Scripts” should be added to the user “Path” value, which is in the upper list of variables in the system environment-variable editor. When the editor is closed, it sends a WM_SETTINGCHANGE “Environment” message to all top-level windows in the current session. Most applications that create top-level windows will ignore this message – except Explorer, which handles it by reloading its environment from the registry. Any processes that are subsequently spawned by Explorer will have the updated environment.

Console/terminal processes such as instances of cmd.exe, pwsh.exe, and python.exe are usually unaware of the WM_SETTINGCHANGE message because they usually don’t create any windows. To get the updated PATH value, either open a new terminal from Explorer or manually update the PATH environment variable in an existing instance of the shell. For example, in CMD run set PATH=%PATH%;%AppData%\Python\Python311\Scripts.

Note that the path that pip displays should be reported as a bug. Programs should never use “%USERPROFILE%\AppData\Roaming” instead of “%AppData%”. The default location of a user’s roaming application-data directory is “%USERPROFILE%\AppData\Roaming”, but it’s trivial to relocate it to another local or remote path via the “Location” tab of the folder properties, or via system policy.

If you’ve installed for all users in “%ProgramFiles%”, then you should run pip from a shell with administrator access. If you don’t, then by default pip does a --user installation without even confirming that you want it. Personally I only ever want a --user installation if I’m explicitly testing how it works. If I mistakenly forget to use a shell with admin access, the default behavior only exacerbates my mistake by making me have to remove the per-user package installation that I don’t want.

Also, note that a per-user installation of Python does not have an option to add the user “Scripts” directory to PATH. It only has an option to add the installation “Scripts” directory to PATH. By default, for version 3.X, the “Scripts” directory of a per-user installation is “%LocalAppData%\Programs\Python\Python3X[-abi]\Scripts”.

I wish that a per-user installation of Python always used the installation’s “site-packages” and “Scripts” directories, even for a --user package installation. A “python3X.ini” file beside “python3X.dll” could configure whether it’s an all-users installation or per-user installation.