/bin/sh: python: command not found

Looks to me like that is still using just python rather than the interpreter path. Try selecting the /usr/bin/python3 one manually.

I did that and still the same result

Perhaps we can leverage that default interpreter path setting. Try changing that one to /usr/bin/python3

I did that and still the same error also :frowning:

I am sorry. At this point it is beyond my knowledge or skills to solve. I would reach out to support from either the maintainers of the VSCode python extension or else VSCode support looking for help. Otherwise you can just use the terminal as I have already mentioned.

Okay, got it. Thank you so much for your help!

Not sure if you are still having issues with this. Did you ever browse to the directory to see if python3 was located there? Open a terminal and type cd /bin/sh or ls -la /bin/sh. I am also running an M1 air and don’t recall this being an issue. While I use homebrew, I don’t recall installing it through brew. Also, from a terminal type in which python3 to see where python3 is installed. Check that your path variable is set to include that location.

hi I saw the picture you sent, we have the same issue. Any luck?
let me know if you found the solution. I think I can browse my history how I fixed it to help you.

hi, apparently I have not been able to resolve the problem with vscode/python yet. I would love to hear your solution on this problem!

Yes, I did check my directory and I can see that it is all there too which is odd.

you have Mosh python video tutorial right? try following the 9th video on getting started I think
that’s the one that helped me. I think I remember it was little hard for me to understand it cause it was my first time to use vscode and the video was a little short to see what he is pointing. I had a hard time following thehis guide cause the the vscode interface is a bit different now.
He was saying about going to settings of Jason and type code-runner.execu.
if hope my memory is still correct.:smile: I’m setting aside python for awhile sorry if I couldn’t help you right away.

I am very bigger to Python and just stated tutorials by Mosh. following the steps mentioned in the tutorial and have the same error:

"
[Running] python -u “/Users/Mohammad/Desktop/desktop/Learn Python/test1/app.py”
/bin/sh: python: command not found
[Done] exited with code=127 in 0.008 seconds
"
I am using >> Python 3.10.5 and VScode 1.69.2 , MacOS Monterey Version 12.5

Any ideas how to solve this?

i am having the same issue. Currently have homebrew installed Python 3.9.13 with VS Code 1.70.1 with the extension Code Runner v0.11.8

cant seem to get the output to work, but debug console and terminal work fine.

Only reason I would like to Code Runner and use output is for the clean code execution. I’m fairly new to coding and with all the extra directories shown in the terminal it becomes too much. If someone finds a fix pls let us know!

I FINALLY FIXED THE PROBLEM

Like many of you, I had the exact same problem. I downloaded the latest version of python from the official website, I already added the correct path, and I downloaded the code runner extension and it brought up the error /bin/sh: python: command not found. What I finally had to do to fix the problem was this (I did this for mac BTW so try to translate the steps to windows/Linux):

  1. Hold down command + , to go into settings

  2. type in Code-runner: Executor Map in the search bar

  3. Underneath the Code-runner: Executor Map settings click on Edit in settings.json

  4. In the code-runner.executorMap portion of the .json file, make sure In the python section it says “python”: “python3 -u” (Adding the “3” is what’s different) and not just “python”: “python -u”

  5. Save the changes and run the code through code runner again. That’s what made it work for me.

SCREENSHOT OF STEP NUMBER 4 TO THE CORRECT CHANGE BELOW

7 Likes

You could also probably get away with aliasing python to python3:

echo 'alias python=python3' >> ~/.bash_profile # or ~/.zshrc if using zsh

Thank you so much, brother. I was struggling since I bought the mac m1 air (about a month).
really now it’s feeling like it’s worth it, was thinking of trade in a laptop but again thanks for giving a solution.
Appreciated man!

thank you for the solution, i spent a lot of time to solve it, it is working now!!!

bro I just sing up to thank you , thank you so much