Baffled by this. I’ve been using VSCode for a few weeks and have python installed.
def print menu():
print ("Let's play a game of Wordle!")
print ("Please type in a 5-letter word")
print_menu()
print_menu()
So far so simple, but when I run it I get this
[Running] python -u "/Users/davidelks/Dropbox/Personal/worldle.py"/bin/sh: python: command not found [Done] exited with code=127 in 0.006 seconds
What does this mean? I’m guessing it failed but why? This appears to be trivial.
UPDATE:
Tried:
def print menu():
print ("Let's play a game of Wordle!")
print ("Please type in a 5-letter word")
print_menu()
It failed.
4
Answers
Try to end your filename with (.py) or try reloading the python extension.
Try entering the VSCode command. On linux, you can digital control + shift + P.
In the dialog that appears at the top, type:
select python interpreter.
Select option:
Python: select interpreter
After that, select the python interpreter you intend to use with your VSCode and see if it worked.
I ran the code using python3 from my terminal and it executes fine.
The issue is that you are using a binary that doesn’t exist in /bin folder. (
python
in this case.)Trying issuing just
python
andpython3
respectively, with no options and see which ones returns a command not found error.Moreover, python version 2 (meaning, command
python
is deprecated), see: https://www.python.org/doc/sunset-python-2/You have to use python3, so for your case:
This is the code that I ran:
Then, saved it as
python.py
and opened it from the directory:This error means that Python is not installed or your installation is corrupted.
You can enter python in the terminal to check whether the system can correctly identify python environment variables. You can also try reinstalling python.