Persistent Error: Python was not found

Eryk Sun eryksun at gmail.com
Mon Aug 15 03:14:30 EDT 2022


On 8/13/22, Jonathan Owah <owahjonathan at gmail.com> wrote:
>
> I've been trying to configure my laptop to run python scripts.
> This is the error I keep getting:
> Python was not found; run without arguments to install from the Microsoft
> Store, or disable this shortcut from Settings > Manage App Execution
> Aliases.

If you keep seeing this message, then the shell is finding and running
Microsoft's default "python.exe" redirector app execution alias that's
located in "%LocalAppData%\Microsoft\WindowsApps". By default, this
directory is set at the beginning of the user "Path" value in the
registry and thus takes precedence (but not over the system "Path").
Confirm this by running `where.exe python`.

An app execution alias is a special type of filesystem symbolic link
to a store app's executable. These aliases are created in a user's
"%LocalAppData%\Microsoft\WindowsApps" directory. Store apps
themselves are usually installed in "%ProgramFiles%\WindowsApps",
which is a system managed directory that even administrators can't
easily modify (and shouldn't modify). Each user on a system has their
own set of installed store apps, even though the apps are installed
only once at the system level.

By default, Windows creates "python.exe" and "python3.exe" aliases for
the "App Installer" PythonRedirector app. In the alias manager, these
two will be clearly listed as aliases for "App Installer". If you run
this redirector app with one or more command-line arguments, it will
print the above quoted message to the console. If the redirector app
is run without arguments, it will open the Microsoft Store to install
the latest version of the Python store app distribution. Currently
that means Python 3.10.

In my experience, the app execution alias manager component of Windows
is unreliable. A disabled alias might still exist in
"%LocalAppData%\Microsoft\WindowsApps", or an old alias might be left
in place when an app is installed.  Once the real Python store app is
installed, go back into the alias manager and toggle the "python.exe"
and "python3.exe" aliases off and back on. If that doesn't resolve the
problem, manually delete the "python.exe" and "python3.exe" aliases
from "%LocalAppData%\Microsoft\WindowsApps". Then toggle them off and
on again in the alias manager. Hopefully they'll be created to
correctly alias the real Python app instead of the "App Installer"
redirector.


More information about the Python-list mailing list