1

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.

8
  • 2
    def print menu() -> def print_menu() Commented Dec 23, 2022 at 16:27
  • 2
    It means your computer did not recognize the command python. Either it was installed as some other name (perhaps python3), or the installation process did not add it to your PATH. (Or, possibly, it did, but you need to reboot...) Commented Dec 23, 2022 at 16:27
  • 1
    and have python installed How, exactly, did you install it? Commented Dec 23, 2022 at 16:29
  • John Gordon, yes I did.It's just not working and I don't have an option to remove and then reimport. Instead I get disable which is not what I want. Commented Dec 23, 2022 at 16:40
  • Yash Mehta I've had python installed and Commented Dec 23, 2022 at 16:45

6 Answers 6

1

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 and python3 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:

python3 -u /Users/davidelks/Dropbox/Personal/worldle.py 

This is the code that I ran:

def print_menu():
    print ("Let's play a game of Wordle!")
    print ("Please type in a 5-letter word") 

print_menu()

Then, saved it as python.py and opened it from the directory:

user@localhost:~/Documents/test-realm $ python3 ./python.py 
Let's play a game of Wordle!
Please type in a 5-letter word
user@localhost:~/Documents/test-realm $ python3 python.py
Let's play a game of Wordle!
Please type in a 5-letter word
user@localhost:~/Documents/test-realm $ 
Sign up to request clarification or add additional context in comments.

Comments

1

[Running] python -u "/Users/davidelks/Dropbox/Personal/worldle.py" /bin/sh: python: command not found

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.

Comments

0

Try to end your filename with (.py) or try reloading the python extension.

2 Comments

I've done that. How do I reload the python extension?
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

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.

Comments

0

I'm not an expert but after a few attempts it was enough to select: run the file in python to get everything back to working properly. I apologize for the Italian texts of my vscenter image description here

Comments

0

Run your code through "Run Python File." It will be fixed. For clear view, see the image. see the image

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.