[issue24757] Installing Py on Windows: Need to restart or logout for path to be added

Forrest Shields report at bugs.python.org
Thu Sep 24 12:01:53 EDT 2020


Forrest Shields <forrestshields2 at gmail.com> added the comment:

As of 3.8.5 the current shell's PATH is outdated after a commandline system-wide installation.  This makes it very difficult to do a scripted install of Python followed by the `python` or `pip` commands, as they will not be found. In addition to modifying the PATH in the system scope, the PATH should also be modified for the current process (shell).

Here is the WORKAROUND I created and am currently using:

1. Perform the commandline system-wide installation from an Administrative PowerShell prompt.
2. After the installation (but before using `python` or `pip`) rebuild the PATH environment variable for the current process from the concatenation of the PATH environment variables from the System and User scopes (this is how Windows builds the PATH) by using this code:
```
[Environment]::SetEnvironmentVariable('PATH', [Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' + [Environment]::GetEnvironmentVariable('PATH', 'User'), 'Process')
```

----------
components: +Installation
nosy: +forrestshields2
versions: +Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue24757>
_______________________________________


More information about the Python-bugs-list mailing list