CMD opens window store when I type python

前端 未结 9 1808
天涯浪人
天涯浪人 2020-11-27 17:31

Today when I tryed to run a simple code on Sublime Text 3, the following message appeard:

Python was not found but can be installed from the Microsoft

相关标签:
9条回答
  • 2020-11-27 18:11

    The main problem here is that the order in the path calls the windows from top to bottom, and that there is python.exe in %USERPROFILE%\AppData\Local\Microsoft\WindowsApps which is called first if there are no other python.exes in the PATH above that line.

    To ensure that the correct python.exe is called, add the python installation folder (containing python.exe) to the PATH, above %USERPROFILE%\AppData\Local\Microsoft\WindowsApps

    Here is an example:

    • To get to this location, click "Start" -> start typing "Env" -> Select "Edit the system environment variables" -> "Environment variables" -button -> Select the entry for "Path" in the upper list -> Click "Edit".

    enter image description here

    • Python components should be at the top, as in step 5. If not, move up by pressing the button in step 6.
    0 讨论(0)
  • 2020-11-27 18:16

    You can manually add Python to windows path by doing this

    1. Start the Run box and enter sysdm.cpl

    1. Go to the Advanced tab and click the Environment Variables button

    1. Now you’ll need to locate the relevant Python paths

    Here is how a Python application path looks like:

    And this is how a Python Scripts path looks like:

    1. Select the Path variable, press edit and add both paths (Python application and Python Scripts)

    4a. If it doesn't show, press new instead of edit and fill the New User Variable box

    This is how my Variable value looks like:

    C:\Users\Ron\AppData\Local\Programs\Python\Python37-32;C:\Users\Ron\AppData\Local\Programs\Python\Python37-32\Scripts

    That’s it! You just added Python to the Windows Path.

    Source: Data To Fish

    0 讨论(0)
  • 2020-11-27 18:17

    Just download python from the website and install.

    Remember to select Add python to path.

    0 讨论(0)
  • 2020-11-27 18:20

    Two solutions:

    1. As ChipJust said it may be possible to use "py" as the new alias for python in Windows10.

    2. As explained here https://devblogs.microsoft.com/python/python-in-the-windows-10-may-2019-update/, use the search bar to find "Manage App Execution Aliases". There should be two aliases for python, see image, unselect them, which will allow the usual python aliases "python" and "python3"

    This works because Microsoft created the %USERPROFILE%\AppData\Local\Microsoft\WindowsApps dir for the Execution Alias system. There is a empty or "fake" *.exe in that dir because that essentially is the alias. What is really cool about MS's implementation, is that disabling the alias deletes the empty *.exe. Thus when you type the alias python, or spotify, etc, in cmd, Windows searches for the alias but won't find the empty *.exe anymore, and instead keeps searching the PATH until it finds the *.exe at the installed location if on the PATH. It is beneficial because you don't have to keep reodering the path for every new program you install that also has an alias, and based on the blog post by MS, it seems like this is the intended use.

    0 讨论(0)
  • 2020-11-27 18:22

    If python is already installed, then go to Apps & features from settings, select Python, then select modify. Again select modify and select next

    Select next, then this window will appear select add python to environment variable

    and click on the install button. then again go to apps & features, click modify and then click repair. Now go to CMD and type python. problem solved.

    0 讨论(0)
  • 2020-11-27 18:32

    This is a powershell script that does the magic.

    Remove-Item $env:USERPROFILE\AppData\Local\Microsoft\WindowsApps\python*.exe
    
    0 讨论(0)
提交回复
热议问题