skip to Main Content

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.

Tried:

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

Although I get an error on running script I can get an interpreter from python3.

2

Answers


  1. Error 127 in Bourne shell refers to a command not existing, you do not have python installed most likely, or it’s not in PATH.

    Also you have a space in print_menu‘s definition.

    Re-install python, fix the error and try again.

    You can reinstall by downloading the installer from Python’s website for windows/in general, on linux (ubuntu/debian) you can run

    $ sudo apt-get install --reinstall python
    

    Remember to also make sure that Python is added to PATH, after installing and rebooting, run:

    $ python --version
    

    If it shows the version it should work, otherwise it was not installed or not added to PATH

    Note, the first code shown is not possible to be ran because it has incorrect indentation, and were it fixed it’d have infinite recursion, the correct form of script you most likely desire is the last one shown with the underscore correctly placed.

    Login or Signup to reply.
  2. First of all your function name is incorrect, you should keep the definition and call with the same name.

    Then you can tell from your output that you are using Code Runner to run the code. You should install the official extension Python to run the code. You also need to have a python interpreter installed on your machine before installing the extension.

    enter image description here

    It would be helpful to follow this documentation to get started.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search