简体   繁体   中英

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.

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.

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.

在此处输入图像描述

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

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.

Looking closer I also notice you are using Dropbox, you might not be able to use python directly onto Dropbox, but do check if it works outside of Dropbox.

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 like desire is the last one shown.

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