简体   繁体   中英

Why does Windows not see python.exe?

Update 3: Found it - it's a "helpful" feature of Windows to go find apps via the Windows store ( details here ).

I installed Anaconda (following a Udacity course) and am trying to get it set up right to run on Windows. The Udacity course assumes I have Git Bash (I don't) and so it's not much help.

I added the following to the path:

  • C:\\Users\\david\\anaconda3
  • C:\\Users\\david\\anaconda3\\Scripts

When I run "conda --version" I get the expected version number. But when I run "python --version" I get:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>python --version
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>

When I run "path", it is there:

... 
Studio\bin;C:\Users\david\.dotnet\tools;C:\Users\david\AppData\Local\GitHubDesktop\bin;C:\Users\david\anaconda3;C:\Users\david\anaconda3\Scripts;C:\Program Files\JetBrains\PyCharm 2021.1.2\bin;;;C:\Program Files (x86)\Microsoft Visual St
...

And explicitly setting the location of python.exe works:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>\users\david\anaconda3\python --version
Python 3.8.8

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>

So why does it not find it when I just run python?

Update: Yes I opened a new command window after saving the additions to the path (always a good question to ask though).

For running where:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>where python
C:\Users\david\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Users\david\anaconda3\python.exe

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>

So it finds it under where, but not when trying to run it.

Update 2: Is it possible that Windows does not want to run apps under the c:\\users folder for security reasons? It's an unusualy place to put a .exe.

This is mostly a guess since you haven't provided the full value of your PATH variable, but I think the entry for your Anaconda folder occurs after the entry for <user>\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe so it gets hidden.

Windows searches the folders in PATH in order and executes the first python.exe file that it finds, which in this case is the message saying to download Python from the Store.

Try making \\users\\david\\anaconda3\\ as the first value in your PATH value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM