/bin/sh: python: command not found

Hi, I’m a beginner in learning python and just installed vscode in my m1 MacBook Air.
after installing code runner extension and creating a short python print command sample and pressing run code OUTPUT it says " //bin/sh: python: command not found

[Done] exited with code=127 in 0.006 seconds "


Hello SyntaxError, it looks to me like you forgot to install python on your MacBook Air. Here are some generic instructions for installing Python on Mac: 5. Using Python on a Mac — Python 3.10.5 documentation

Alternatively, it is possible that VSCode is looking for the python binary in the wrong place. Here are the instructions for running Python in VSCode: Get Started Tutorial for Python in Visual Studio Code

Hello jmrunkle, i have it installed python 3.10.5 multiple times but I don’t know what’s wrong with it. when I type "python"in my terminal it say’s command not found, but when I type python3 it shows information but nothing happens on vscode output it still says command not found.

1 Like

I got it working installing python 3 using homebrew I don’t know what’s happening just new in using apple Macbook so I don’t know this things . I believe I already installed python 3.10.5 in it which is not working but Homebrew installed python3.9.13 instead. Any idea about this or what is happening?

1 Like

Possibly this:

The system install of Python on macOS is not supported. Instead, an installation through Homebrew is recommended. To install Python using Homebrew on macOS use brew install python3 at the Terminal prompt.

Get Started Tutorial for Python in Visual Studio Code

Thank you jmrunkle.
My VSCode run output is now working!
Now I’m researching how to update the Python 3.9 version that Homebrew installed.

Based on this, it looks like you can use:

brew install python@3.10

Assuming you want it to install 3.10.5 (currently).

NOTE: I highly doubt there are significant changes between 3.9 and 3.10 that will affect your work. You can probably just use 3.9.13 as installed already and just update whenever homebrew updates their stable version.

Yeah i think I’ll just use the 3.9 version , I couldn’t install the 3.10.5 there’s a guide on it but i don’t know how to follow it it’s a hard for me at this time need more experience on using mac os.
Thanks you jmrunkle!

1 Like

Do you mind telling me how you solved it because I’m having the same issue and I tried almost everything including an install with brew but it is still not working with the error :frowning:

Did you follow the tutorials linked up here: /bin/sh: python: command not found - #2 by jmrunkle

If so, do you get any output when you type python or python3 in a terminal?

Hi Eozcode sorry i stop my python coding for awhile and i forgot how i did it. Try researching it on youtube. I was stuck for two days searching for it and There was a lot of websites. The one thing that I remember was about homebrew, try to start there. When I remember everything I’ll let know. Good luck

Yes, I followed the guide and did many times with and without homebrew also following many youtube guide with different settings but still the same error. If I run code on terminal it works but when I use code runner then it shows the error so I figured it must be the extension that is causing trouble.

Did you select the right python interpreter? Get Started Tutorial for Python in Visual Studio Code

If you have python installed correctly, it seems likely that VSCode is just looking for it in the wrong place.

I did everything correctly and was also thinking vscode couldn’t find it so I check its PATH and it is all there

Not sure PATH matters, the python interpreter selected by the extension seems unrelated to the PATH variable.

PATH → if vscode is reading everything where it supposed to be.
interpreter → selected the correct version along with its location verification and all (of code runner extention)

maybe I’m watching too many tutorials LOL
but I triple checked the interpreter many times making sure I select everything correctly

Ok, maybe it is time for some screenshots and output summaries. Can we get:

  1. Screenshot(s) of what it looks like when you try to run your python file (ie, what buttons you click on, what interpreter is selected, etc).
  2. What extensions do you have installed on VSCode?
  3. Paste (or screenshot) of the python extension’s settings.

In the worse case scenario, you should be able to get by just running Python in the terminal (using python somefile to run the code in somefile). It is not that bad to get used to running commands in the terminal anyway.

1 Like

Perhaps also the exact command output including the command invocation by VSCode.