简体   繁体   中英

How to solve error in VS Code - exited with code=127

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.

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 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 $ 

[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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM