Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Persistent Error: Python was not found

309 views
Skip to first unread message

Jonathan Owah

unread,
Aug 14, 2022, 11:08:15 PM8/14/22
to
Good day,
Great job on making Python easily accessible.

I'm using a Windows 10, 64gb HP EliteBook.

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.

Everything I've tried has failed.
I've uninstalled and reinstalled
I've added to path, both user and system path,manually and from fresh
installation
I've downloaded from Microsoft Store
I've gone to manage app aliases and switched off
I've used Git Bash, Powershell, cmd

I'm able to check my python version: 3.10.6.

I can't do anything else and it's really frustrating.

I've been at it for days, I don't know what else to do.

Thanks in advance for your help.

Regards

Mike Dewhirst

unread,
Aug 15, 2022, 12:46:15 AM8/15/22
to
Jonathan

This is what I would do ...

1.    Download Python from python.org not Microsoft

2.    Install as an expert or custom install to C:\Python310 rather than
C:\Program files

3.    Ignore this point - I was going to mention VirtualEnv which comes
later for software development and thereafter you don't need to put
Python on the Windows path. As I said, ignore this point.

4.    Add C:\Python310\Scripts to the path (system or user)

5.    Add C:\Python310 to the path after C:\Python310\Scripts

6.    Open a cmd prompt and enter python to prove it starts then quit.
Exit the cmd window

7.    Create a directory in the root of your user profile
(C:\Users\Jonathan ??) called pythontest

8.    Save 'print("hello world")' in a text file called hello.py in the
above directory

9.    Open a cmd prompt and type > python
C:\Users\Jonathan\pythontest\hello.py

Should work.

If you want to execute a python script without first opening a cmd
prompt, you need a bat file or shortcut which contains the command line
you want executed. Give that a double-click and it should also work.

If Python is on the path you don't need to specify where it is.

You do need to tell Python what you want it to execute.

It is possible that you can associate .py files with Python but that
would be a step too far for me.

Good luck

M
--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

OpenPGP_signature

Barry

unread,
Aug 15, 2022, 2:55:23 AM8/15/22
to


> On 15 Aug 2022, at 04:10, Jonathan Owah <owahjo...@gmail.com> wrote:
>
> Good day,
> Great job on making Python easily accessible.

Try using the python launcher py.exe.
It is documented here https://docs.python.org/3/using/windows.html#python-launcher-for-windows
That page documents lots of other things that you may need to know about on windows.

Barry

>
> I'm using a Windows 10, 64gb HP EliteBook.
>
> 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.
>
> Everything I've tried has failed.
> I've uninstalled and reinstalled
> I've added to path, both user and system path,manually and from fresh
> installation
> I've downloaded from Microsoft Store
> I've gone to manage app aliases and switched off
> I've used Git Bash, Powershell, cmd
>
> I'm able to check my python version: 3.10.6.
>
> I can't do anything else and it's really frustrating.
>
> I've been at it for days, I don't know what else to do.
>
> Thanks in advance for your help.
>
> Regards
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Eryk Sun

unread,
Aug 15, 2022, 3:14:52 AM8/15/22
to
On 8/13/22, Jonathan Owah <owahjo...@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.

Jonathan Owah

unread,
Aug 15, 2022, 5:11:45 AM8/15/22
to
Thank you so much for your assistance .

The fault was actually mine: I was running a command
with python3, instead of just python.
python3 works for Mac, but not Windows.

I'm fairly new to Python so I was just following along a
tutorial, and I didn't take note of the fact that the command
didn't work because the tutorial was done on a MacBook,
while I'm using a Windows device.

Thanks for your help,
Regards

Eryk Sun

unread,
Aug 15, 2022, 5:41:46 AM8/15/22
to
On 8/15/22, Jonathan Owah <owahjo...@gmail.com> wrote:
> Thank you so much for your assistance .
>
> The fault was actually mine: I was running a command
> with python3, instead of just python.
> python3 works for Mac, but not Windows.

If the Python 3.10 store app is installed with all aliases enabled,
then "python", "python3", and "python3.10" all work. The standard
distribution from python.org, on the other hand, only has a "python"
executable.

Dennis Lee Bieber

unread,
Aug 15, 2022, 10:28:19 AM8/15/22
to
On Mon, 15 Aug 2022 14:38:25 +1000, Mike Dewhirst <mi...@dewhirst.com.au>
declaimed the following:

>If you want to execute a python script without first opening a cmd
>prompt, you need a bat file or shortcut which contains the command line
>you want executed. Give that a double-click and it should also work.
>

I've never had to do that... But I have file associations set up so
that .py is considered to be an executable file.

Just double-clicking on the file will run it. The problem is that it
will open a command shell, run, and then close the command shell UNLESS one
explicitly codes some sort of "hold" at the end of the program

jnk = input("Press return to exit")

.pyw extension does not open the command shell -- but is meant for
programs that use one of the various GUI frameworks, which is probably more
than the new-comer is ready to attack.


--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

Gisle Vanem

unread,
Aug 15, 2022, 12:00:23 PM8/15/22
to
Eryk Sun wrote:

> 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.

That is true with cmd. But with a shell like 4NT, I get:
c:\> "%LocalAppData%\Microsoft\WindowsApps\python.exe"
4NT: (Sys) No access to the file.
"C:\Users\gvane\AppData\Local\Microsoft\WindowsApps\python.exe"

No matter what I do with this "App Alias" setting.
What a broken and confusing design this AppX design is.


--
--gv

Eryk Sun

unread,
Aug 15, 2022, 12:35:31 PM8/15/22
to
An app execution alias is a reparse point with the tag
IO_REPARSE_TAG_APPEXECLINK (0x8000001B). Neither the I/O manager no
any driver in the kernel supports this type of reparse point. For
better or worse, this is intentional. As such, if CreateFileW() is
called on an alias without using the flag
FILE_FLAG_OPEN_REPARSE_POINT, the attempt to traverse the link fails
with ERROR_CANT_ACCESS_FILE (1920). Note that Python's os.stat() was
updated to open the reparse point directly in this case instead of
failing. But a lot of applications, in particular non-Microsoft shells
such as MSYS bash (and apparently 4NT) haven't been updated similarly.

Even if the link could be traversed, the target file under
"%ProgramFiles%\WindowsApps" doesn't grant execute access to users
unless they have an access token that includes a WIN://SYSAPPID
attribute that corresponds to the executed app. How this works in
practice when executing an app is that CreateProcessW() handles
ERROR_CANT_ACCESS_FILE by opening the reparse point, reading the
relevant app information, and creating a custom access token that
allows it to execute the app directly via the internal equivalent of
CreateProcessAsUserW().

Eryk Sun

unread,
Aug 15, 2022, 12:47:15 PM8/15/22
to
On 8/15/22, Dennis Lee Bieber <wlf...@ix.netcom.com> wrote:
>
> Just double-clicking on the file will run it. The problem is that it
> will open a command shell, run, and then close the command shell UNLESS one
> explicitly codes some sort of "hold" at the end of the program

The console window is a terminal, not a shell. If an application is
flagged as a console app, as is "python.exe", and the process doesn't
inherit a console, the initialization code in kernelbase.dll allocates
a new console session. This could be implemented by the classic
conhost.exe host, or, in Windows 11, by an openconsole.exe session
that's associated with a tab in Windows Terminal. If it's the latter,
Terminal can be configured to keep a tab open after the console
session has ended. The tab will display the exit status of the process
that allocated the console session.
0 new messages