41

I started watching a Python course on YouTube in which the guy giving the lesson teaches using VSCode. He started with software installation (Python & Pycharm). Then, in VSCode he downloaded the Python extension (the one made by Microsoft) and the extension called "Code Runner" to run the Python code on VSCode. When I try running my code it hits me with the following error which you can also see in the image on the link at the end of the question. I'm not able to post a screenshot of it because I'm new on this platform. Thanks to whoever sees this.

[Running] python -u "c:\Users\Ryan\Desktop\Python\app.py" Python was not found but can be installed from the Microsoft Store: htttps://go.microsoft.com/fwlink?linkID=2082640

Screenshot of the VSCode error screen:

enter image description here

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Luis M.
  • 597
  • 2
  • 5
  • 13
  • Does this answer your question? [CMD opens Windows Store when I type 'python'](https://stackoverflow.com/questions/58754860/cmd-opens-windows-store-when-i-type-python) – starball Jun 07 '23 at 02:50

10 Answers10

33

You don't have the command python installed into your PATH on Windows which is the default if you didn't get your copy of Python from the Windows Store. If you selected your Python interpreter in VS Code (look in the status bar), then I would disable Code Runner. That way the Python extension is what provides the ability to run Python (the Play button will be green instead of white).

Brett Cannon
  • 14,438
  • 3
  • 45
  • 40
  • Thanks, it worked and ran the code. When I run it, this is the output: PS C:\Users\Luis\Desktop\Python> & C:/Users/Luis/AppData/Local/Programs/Python/Python38-32/python.exe c:/Users/Luis/Desktop/Python/app.py Hello, Baby PS C:\Users\Luis\Desktop\Python> And I'd like it to look a little cleaner, like Pycharm's output that looks like this: C:\Users\Luis\PycharmProjects\python0\venv\Scripts\python.exe C:/Users/Luis/Desktop/Python/app.py Hello, Baby Process finished with exit code 0 It might look alike, but I couldn't post the screenshots in this comment. – Luis M. Mar 27 '20 at 19:25
  • @devloop please don't forget to thank the gentleman that helped you by up-voting his response. – Chadee Fouad Mar 29 '20 at 02:37
  • 1
    @ShadyMBA I already did but I don't have enough reputation for it to be publicly displayed. – Luis M. Mar 29 '20 at 22:11
21

python install directory, bin, and lib-scripts must be to the top of WindowsApps directory, like the image below

enter image description here

Erfan Eghterafi
  • 4,344
  • 1
  • 33
  • 44
16

Prior to do "start -> then search -> Manage App Execution Aliases -> turn off" make sure that you have added PYTHONPATH with details (C:\Program Files\Python37;) in system-environment-variable. Then do the "turn-off" as mentioned above. This will work

Aniyarath
  • 161
  • 1
  • 2
  • That Manage app Execution Aliases have more than 10 apps here in my Windows 11, Should I turn off every one of them. – 0_0perplexed Jun 03 '22 at 17:08
11

Go to start -> then search -> Manage App Execution Aliases -> turn off

Raj Kalathiya
  • 385
  • 2
  • 8
8

I think you need to install python from microsoft window store. enter image description hereAnd also install python from python.org

kouk
  • 1,453
  • 12
  • 12
Bipul Kumar
  • 81
  • 1
  • 1
4

Type Python3 in console window. It will take you to Microsoft Store for installing Python. enter image description here

ZealousWeb
  • 1,647
  • 1
  • 10
  • 11
1

I had the same problem (and others).

Finally it was caused due to multiple Python installations.

I had already installed once python in C:\Programs\Python\python38-32 (in system's PATH) and used it in command line.

So while installing of Visual Studio Code - I assume - another instance of Python was (automatically) installed to c:\users<username>\appdata\local\programs\python\python37-32. And I had both installation locations in the PATH variable:

  • c:\users<username>\appdata\local\programs\python\python37-32 in user's PATH
  • and C:\Programs\Python\python38-32 in the system's PATH variable.

So I removed the path C:\Programs\Python\python38-32 from the system's environment variable PATH. Restarted Visual Studio Code.

And so I could now run "pip install flask" without complaining about pip should be updated from 19.x to 21.y - what was an additional strange behavior in my case.

Afterwards I could run the code in the Visual Studio Code's terminal by e. g. "python webapp.py".

BitLauncher
  • 587
  • 4
  • 15
0

Sometimes this happens if you are using a virtual environment and you have not activated it on your command prompt.

Misan
  • 177
  • 1
  • 6
0

PS C:\Users\preet\Documents\django-project> py get-pip.py

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

PS C:\Users\preet\Documents\django-project> py -m ensurepip --upgrade

Looking in links: c:\Users\preet\AppData\Local\Temp\tmp9k7p19jq Processing c:\users\preet\appdata\local\temp\tmp9k7p19jq\setuptools-56.0.0-py3-none-any.whl Processing c:\users\preet\appdata\local\temp\tmp9k7p19jq\pip-21.1.3-py3-none-any.whl Installing collected packages: setuptools, pip WARNING: The scripts pip3.9.exe and pip3.exe are installed in 'C:\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed pip-21.1.3 setuptools-56.0.0

Preeti Duhan
  • 87
  • 2
  • 6
-2

I think you need to install Python first before using VSCode. You can download it from here: https://www.python.org/downloads/

Once it is installed, VSCode should detect it and run without problems.

Chadee Fouad
  • 2,630
  • 2
  • 23
  • 29
  • Hello, thanks for answering. I installed Python 3.8.2 a few months after installing and started using VSCode. I've been using VSCode for basic HTML, CSS and PHP for about 3 months now. What you're suggesting is that I uninstall VSCode and reinstall it? I was told on Reddit that it may be an issue in the Path on the environment variable settings. – Luis M. Mar 25 '20 at 20:46
  • I also have to add that PyCharm runs it nice, maybe is a little irrelevant because is basically a Python IDE but I wanted to add that just in case it's somehow useful. – Luis M. Mar 25 '20 at 20:54
  • Let's test if your PC can see Python properly....try opening the command prompt and type 'Python' from any directory does it give you something like this? ```'Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.``` – Chadee Fouad Mar 26 '20 at 02:58
  • Well, when I type "Python" on the CMD it opens Python on the Windows Store for me download it. – Luis M. Mar 27 '20 at 19:11
  • Did you add Python to Windows Path? – Chadee Fouad Apr 04 '20 at 03:03
  • I don't really know how to do that. I mean, it's on the environment path variables. I can run it on PyCharm with no issues. I can also run it on VSCode (shoutout to Brett Cannon for the answer) but the output on the terminal looks a little overcharged with address of my proyect. It's not ideal, but I can live with it. Thanks for checking out. – Luis M. Apr 04 '20 at 20:52
  • I hear you I'm looking for an IDE myself...most of the ones I've found are very complicated and require lots of configurations...I've just tried PyScripter...and although the gui is not the best it is very simple and very easy to use to give it a shot there are tons of IDEs out there so try them out till you find the one you like! – Chadee Fouad Apr 05 '20 at 05:44
  • Hey. Thanks for the advice, I personally like VSCode so I plan to stick to it for some time. I wish you luck with finding your ideal IDE. There's one I haven't tried but hear a lot about it, it's called Atom, maybe (if you haven't already) you should give it a try. Have a nice day! – Luis M. Apr 07 '20 at 20:04
  • You're welcome! PyScripter's big advantage over VsCode is speed. It opens super fast...and also it is designed exclusively for Python so there are no complex configurations...it runs out of the box! I love it and it is exactly what I needed...good luck! :-) – Chadee Fouad Apr 08 '20 at 03:44