Code runner issue on Mac

Does anyone know why my code runner (ctrl + alt + n) is giving me this message when I run it on vsc mac

"[Running] python -u “/Users/chiemelienwanisobi/Desktop/Python/Python Practice/app1.py”

/bin/sh: python: command not found

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

Seems like either you do not have python installed or else the path to the Python binary is not in your PATH variable. You could just make the code runner extension use the full path to the Python binary if you know where it is installed. You might also have python installed as python3 so that’s another thing you could try.

1 Like

I don’t understand what you mean. But in the course it does say something about updating python -u to python3. But I can’t find where to

If you open the terminal application and type the following what do you get?

echo $PATH

Same for this:

which python

And this:

which python3

Which python3: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3

echo $PATH: /Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

So it looks like you need to change it to using python3 rather than python. You can also create an alias to python3 for python either by making a symlink or simply by adding a line to ~/.bashrc or ~/.profile:

alias python="python3"

I’m sorry. I didn’t mention I am not a coder. I am taking this course to use on financial data. I don’t understand what u just typed

Terminal and Shell will give you a simple understanding and some background on a terminal and a shell.

Once you understand the difference, I would suggest you do a spotlight search on your mac for the terminal application, just to actually see the terminal on your computer. Then, check out the VS Code Terminal.

At this point you should have a pretty good idea what a terminal is, what the one on your computer is and how to find it, and the difference/similarities from the terminal on your computer and the one integrated in VS Code.

Now you just need to learn how to use it. If you are running a newer OS, then the default shell will most likely be the zsh shell, older OS versions used bash shell. Yes, there are many different shells you can use. In either case, the commands are mostly the same in either of those shells. I typically suggest people check out The Linux Journey : The Command Line. Yes, I know it says Linux and not Unix or MacOS. Without going into the history of computers…you can use those commands in your shell. You will come across a lot of basic commands that can really help you out in programming and just using a computer in general. One of the commands you will learn about is the alias command which @jmrunkle mentioned.

You are probably thinking…wtf, I just wanted to write something in python, and now you are saying to read about all this extra stuff. Programming is a lot more than just learning a language and off you go. You can totally learn the basics of Python and build programs with just the course, but you are going to always be using some tool to do it, so you will need to know what the tools are and how they work.

2 Likes

This is what helped me: VSCode Python Running ommand Error: /bin/sh: python: command not found - Stack Overflow

Hello Guys,
am a new bride to Python (LOL), bought this amazing course to study but having issues with Class 9 “Running Python Code” Where the use of Ctrl + alt + n comes in.
i watched the clip like more than 10x can’t find solution to my problem.

keep getting this…

python -u “/Users/ig/Desktop/HELLO WORLD /Class 9”

/bin/sh: python: command not found

[Done] exited with code=127 in 0.019 seconds

*** The thing is am stuck from progressing as per am using Mac not window. And i need get this working so that i can progress with this course with MOsh. Anyone to help me out PLEASE? Thanks

Install CodeRunner — Go To – CodeRunner Setting — Code-Runner: Executor Map ----- Edit in setting. JSON ----- change “python": "python -u”, to “python": "python3 -u”,