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.

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


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

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. 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 $ 
    
    Login or Signup to reply.
  4. [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.

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